Class FileDatabase

java.lang.Object
io.github.pigaut.sql.database.FileDatabase
All Implemented Interfaces:
Database

public class FileDatabase extends Object implements Database
  • Constructor Details

    • FileDatabase

      public FileDatabase(File file)
  • Method Details

    • isConnected

      public boolean isConnected()
      Specified by:
      isConnected in interface Database
    • openConnection

      public void openConnection()
      Specified by:
      openConnection in interface Database
    • closeConnection

      public void closeConnection()
      Specified by:
      closeConnection in interface Database
    • createStatement

      public DatabaseStatement createStatement(String sql)
      Description copied from interface: Database
      Creates a statement for this database with the given sql
      Specified by:
      createStatement in interface Database
      Parameters:
      sql - the sql statement
      Returns:
      a new DatabaseStatement
    • getDataSource

      public DataSource getDataSource()
      Description copied from interface: Database
      Retrieves the DataSource associated with this database.
      Specified by:
      getDataSource in interface Database
      Returns:
      The DataSource instance used for database connections.
    • createTableIfNotExists

      public void createTableIfNotExists(String name, String... columns)
      Specified by:
      createTableIfNotExists in interface Database
    • dropTable

      public void dropTable(String table)
      Specified by:
      dropTable in interface Database
    • renameTable

      public void renameTable(String table, String newName)
      Specified by:
      renameTable in interface Database
    • addColumn

      public void addColumn(String table, String columnDefinition)
      Specified by:
      addColumn in interface Database
    • renameColumn

      public void renameColumn(String table, String column, String newName)
      Specified by:
      renameColumn in interface Database
    • clearTable

      public void clearTable(String table)
      Specified by:
      clearTable in interface Database
    • insert

      public DatabaseStatement insert(String table, String... columns)
      Specified by:
      insert in interface Database
    • merge

      public DatabaseStatement merge(String table, String primaryKey, String... columns)
      Specified by:
      merge in interface Database
    • selectAll

      public DatabaseStatement selectAll(String table)
      Specified by:
      selectAll in interface Database
    • execute

      public void execute(String sql)
      Description copied from interface: Database
      Executes a SQL statement against the database.
      Specified by:
      execute in interface Database
      Parameters:
      sql - The SQL statement to execute.
    • executeUpdate

      public int executeUpdate(String sql)
      Description copied from interface: Database
      Executes an SQL statement that may modify the database (such as INSERT, UPDATE, DELETE).
      Specified by:
      executeUpdate in interface Database
      Parameters:
      sql - The SQL statement to execute.
      Returns:
      The number of rows affected by the statement.
    • executeLargeUpdate

      public long executeLargeUpdate(String sql)
      Description copied from interface: Database
      Executes a large update SQL statement that may modify the database.
      Specified by:
      executeLargeUpdate in interface Database
      Parameters:
      sql - The SQL statement to execute.
      Returns:
      The number of rows affected by the statement.
    • executeQuery

      public void executeQuery(String sql, QueryReader reader)
      Description copied from interface: Database
      Executes an SQL query and processes the results using a QueryReader.
      Specified by:
      executeQuery in interface Database
      Parameters:
      sql - The SQL query to execute.
      reader - The QueryReader implementation to process the query results.
    • executeRowQuery

      public void executeRowQuery(String sql, QueryReader reader)
      Description copied from interface: Database
      Executes an SQL query and processes the results using a QueryReader.
      Specified by:
      executeRowQuery in interface Database
      Parameters:
      sql - The SQL query to execute.
      reader - The QueryReader implementation to process the query results.