Interface IDBAdapter

All Superinterfaces:
IDBAdapterID
All Known Implementing Classes:
DBAdapter, DelegatingDBAdapter, DerbyAdapter, EmbeddedDerbyAdapter, H2Adapter, HSQLDBAdapter, MYSQLAdapter, PostgreSQLAdapter

public interface IDBAdapter extends IDBAdapterID
Abstracts all aspects of a database that are vendor-specific.

Consumers normally obtain an adapter from IDBAdapter.Registry.INSTANCE and use its name and version as an identity. Adapter names are compared without regard to case. Versions are compared numerically by dot-separated components, with missing components treated as zero; consequently, versions such as 8, 8.0, and 8.0.0 have the same logical identity.

Service providers should extend DBAdapter. They must return stable identity values from getName() and getVersion(), and should use the version to distinguish incompatible or materially different adapter behavior. The identity values declared by an extension descriptor are authoritative during registry lookup, even if a provider-created adapter reports different metadata.

Author:
Eike Stepper
No Implement
This interface is not intended to be implemented by clients. Subclass DBAdapter instead.
  • Field Details

  • Method Details

    • getName

      String getName()
      Returns the provider's adapter name. Registry registration and lookup compare this value case-insensitively; the value returned by this method is not lowercased for the caller.
      Specified by:
      getName in interface IDBAdapterID
      Returns:
      the adapter name
    • getVersion

      String getVersion()
      Returns the provider's adapter version. Registry registration and lookup compare dot-separated numeric components and ignore trailing zero components, while the original representation returned here remains available to callers.
      Specified by:
      getVersion in interface IDBAdapterID
      Returns:
      the adapter version
    • isCaseSensitive

      boolean isCaseSensitive()
      Since:
      4.12
    • getDefaultSchemaName

      String getDefaultSchemaName(Connection connection)
      Since:
      4.12
    • createConnectionProvider

      IDBConnectionProvider createConnectionProvider(DataSource dataSource)
      Since:
      4.3
    • modifyConnection

      Connection modifyConnection(Connection connection)
      Since:
      4.5
    • createSchema

      void createSchema(Connection connection, String schemaName)
      Since:
      4.12
    • openSchemaTransaction

      IDBSchemaTransaction openSchemaTransaction(IDBDatabase database, IDBConnection currentConnection)
      Opens a schema transaction through the adapter extension point.
      Since:
      4.14
    • readSchema

      IDBSchema readSchema(Connection connection, String name)
      Since:
      4.2
    • readSchema

      void readSchema(Connection connection, IDBSchema schema)
      Since:
      4.2
    • updateSchema

      void updateSchema(Connection connection, IDBSchema schema, IDBSchemaDelta delta) throws DBException
      Throws:
      DBException
      Since:
      4.2
    • createTables

      Set<IDBTable> createTables(Iterable<? extends IDBTable> tables, Connection connection) throws DBException
      Throws:
      DBException
    • createTable

      boolean createTable(IDBTable table, Statement statement) throws DBException
      Throws:
      DBException
    • dropTables

      Collection<IDBTable> dropTables(Iterable<? extends IDBTable> tables, Connection connection) throws DBException
      Throws:
      DBException
    • dropTable

      boolean dropTable(IDBTable table, Statement statement)
    • getReservedWords

      String[] getReservedWords()
    • isReservedWord

      boolean isReservedWord(String word)
    • getMaxTableNameLength

      int getMaxTableNameLength()
      Since:
      2.0
    • getMaxFieldNameLength

      int getMaxFieldNameLength()
      Since:
      2.0
    • getFieldLength

      int getFieldLength(DBType type)
      Returns the column length for the given database type.
      Parameters:
      type - the DBType to check.
      Returns:
      the supported column length for the type.
      Since:
      4.2
    • isTypeIndexable

      boolean isTypeIndexable(DBType type)
    • convertString

      String convertString(PreparedStatement preparedStatement, int parameterIndex, String value)
      Converts a string before it is bound to a prepared statement.
      Since:
      4.14
    • convertString

      String convertString(ResultSet resultSet, int columnIndex, String value)
      Converts a string read from a result-set column.
      Since:
      4.14
    • convertString

      String convertString(ResultSet resultSet, String columnLabel, String value)
      Converts a string read from a named result-set column.
      Since:
      4.14
    • getSQL92ReservedWords

      String[] getSQL92ReservedWords()
      Returns the SQL-92 reserved words used by the adapter implementation.
      Since:
      4.14
    • appendFieldNames

      void appendFieldNames(Appendable appendable, IDBTable table)
      Appends the field names used by the adapter's table SQL generation.
      Since:
      4.14
    • adaptType

      DBType adaptType(DBType type)
      Provide a way for the DBAdapter to override unsupported DB types with replacements. The default implementation just returns the given type. Subclasses may override single types with replacements.
      Since:
      3.0
    • getJDBCTypeForNull

      int getJDBCTypeForNull(DBType type)
      Returns the JDBC type to use when binding a null value for the given database type.
      Since:
      4.14
    • isValidFirstChar

      boolean isValidFirstChar(char ch)
      Check if a character is valid as first character. (e.g., underscores are forbidden as first character in Derby elements.
      Since:
      4.0
    • isDuplicateKeyTransactionAbort

      boolean isDuplicateKeyTransactionAbort()
      Returns whether a duplicate-key exception aborts the current JDBC transaction and therefore requires a savepoint to recover from it.
      Since:
      4.14
    • isDuplicateKeyException

      boolean isDuplicateKeyException(SQLException ex)
      Check if an exception indicates a constraint violation (duplicate key)
      Since:
      4.0
    • isTableNotFoundException

      boolean isTableNotFoundException(SQLException ex)
      Since:
      4.2
    • isColumnNotFoundException

      boolean isColumnNotFoundException(SQLException ex)
      Since:
      4.2
    • sqlRenameField

      String sqlRenameField(IDBField field, String oldName)
      Since:
      4.2
    • sqlModifyField

      String sqlModifyField(IDBField field)
      Since:
      4.2
    • sqlCharIndex

      String sqlCharIndex(Object substring, Object string)
      Since:
      4.13
    • sqlSubstring

      String sqlSubstring(Object string, Object startIndex, Object length)
      Since:
      4.13
    • sqlSubstring

      String sqlSubstring(Object string, Object startIndex)
      Since:
      4.13
    • sqlConcat

      String sqlConcat(Object... strings)
      Since:
      4.13
    • format

      String format(PreparedStatement stmt)
      Formats a prepared statement for diagnostic output.
      Since:
      4.14
    • format

      String format(ResultSet resultSet)
      Formats a result set for diagnostic output.
      Since:
      4.14
    • convertToSQL

      Object convertToSQL(Object value)
      Converts a Java value to the value used by SQL query execution.
      Since:
      4.14
    • getJDBCDriver

      @Deprecated Driver getJDBCDriver()
      Deprecated.
      As of 4.2 no longer supported because of IP issues for external build dependencies (the vendor driver libs).
    • createJDBCDataSource

      @Deprecated DataSource createJDBCDataSource()
      Deprecated.
      As of 4.2 no longer supported because of IP issues for external build dependencies (the vendor driver libs).