Interface RDBMSDriver

All Known Implementing Classes:
HSQLDBDriver, MySQLDriver, PostgreSQLDriver, SQLiteDriver

public interface RDBMSDriver
RDBMSDrivers represents a way to connect and physically execute queries over a database. This is a wrapper over java.sql which also give access to some useful and driver-specific SQL queries.
A driver may keep a connection open in order to execute queries faster
  • Method Details

    • getDatasource

      DataSource getDatasource()
      Returns the data source handled by this driver.
      Returns:
      the DataSource represented by this driver
    • getConnection

      Connection getConnection()
      A driver may keep a connection open in order to execute queries faster or create a new one each time Returns a JDBC connection to the target database.
      Returns:
      a Connection for the database represented by this driver
    • getJDBCString

      String getJDBCString()
      Returns the JDBC connection string.
      Returns:
      the jdbc connection string
    • hasTable

      default boolean hasTable(String table_name) throws SQLException
      Checks whether a table exists in the target database.
      Parameters:
      table_name - the name of the table
      Returns:
      true iff the database represented by this driver have a table with the given name
      Throws:
      SQLException - iff something bad happen
    • getBaseSelectQuery

      default String getBaseSelectQuery()
      Returns the base SELECT query template.
      Returns:
      the base SELECT query corresponding to this driver
    • getBaseSelectFilteredQuery

      default String getBaseSelectFilteredQuery()
      Returns the base SELECT-with-filter query template.
      Returns:
      the base SELECT query with a WHERE clause corresponding to this driver
    • getBaseTableAlias

      default String getBaseTableAlias()
      Returns the base alias used for tables.
      Returns:
      the base alias used to name tables for this driver
    • getBaseInsertQuery

      default String getBaseInsertQuery()
      Returns the base INSERT query template.
      Returns:
      the base INSERT query corresponding to this driver
    • getBaseSafeInsertQuery

      String getBaseSafeInsertQuery()
      Returns the base safe INSERT query template.
      Returns:
      the base INSERT query which does not create exceptions in case of duplicates corresponding to this driver
    • getBaseSafeInsertSelectQuery

      String getBaseSafeInsertSelectQuery()
      Returns the safe INSERT-SELECT query template.
      Returns:
      the base INSERT query using a SELECT clause which does not create exceptions in case of duplicates corresponding to this driver
    • getTextFieldName

      String getTextFieldName()
      Returns the SQL text-column type name used by this driver.
      Returns:
      the name of the Text field corresponding to this driver
    • getNumberFieldName

      String getNumberFieldName()
      Returns the SQL numeric-column type name used by this driver.
      Returns:
      the name of the Number field corresponding to this driver
    • getCSVCopyQuery

      String getCSVCopyQuery(String tableName, String csvFilePath, char delimiter, int headerSize)
      Returns the SQL query used to bulk-copy CSV data.
      Parameters:
      tableName - table name to store data
      csvFilePath - path to the csv file
      delimiter - delimiter of the csv file
      headerSize - size of the csv header
      Returns:
      the query used to copy a CSV file into the database system
    • dropAllTables

      default void dropAllTables() throws SQLException
      Clears all tables in the database by truncating them.
      Throws:
      SQLException - If an error occurs during database access.
    • dropAllIndexes

      default void dropAllIndexes()
      Drops all indexes in the database except for primary keys.