Class DelegatingDBAdapter

java.lang.Object
org.eclipse.net4j.spi.db.DelegatingDBAdapter
All Implemented Interfaces:
IDBAdapter, IDBAdapterID

public class DelegatingDBAdapter extends Object implements IDBAdapter
Keeps extension metadata authoritative without requiring the created adapter to extend DBAdapter.
Since:
4.14
Author:
Eike Stepper
  • Constructor Details

    • DelegatingDBAdapter

      public DelegatingDBAdapter(IDBAdapter delegate)
    • DelegatingDBAdapter

      public DelegatingDBAdapter(IDBAdapter delegate, String name, String version)
  • Method Details

    • getName

      public String getName()
      Description copied from interface: IDBAdapter
      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 IDBAdapter
      Specified by:
      getName in interface IDBAdapterID
      Returns:
      the adapter name
    • getVersion

      public String getVersion()
      Description copied from interface: IDBAdapter
      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 IDBAdapter
      Specified by:
      getVersion in interface IDBAdapterID
      Returns:
      the adapter version
    • getDatabaseProductNames

      public String[] getDatabaseProductNames()
      Description copied from interface: IDBAdapter
      Returns the JDBC database product names recognized by this adapter. Product names are trimmed and compared case-insensitively. The default recognizes the adapter's declared name. Implementations may return additional aliases.
      Specified by:
      getDatabaseProductNames in interface IDBAdapter
      Returns:
      the exact JDBC product names recognized by this adapter
    • getDatabaseProductNamePattern

      public String getDatabaseProductNamePattern()
      Description copied from interface: IDBAdapter
      Returns an optional regular expression for additional JDBC product-name matching. It is matched case-insensitively against the complete trimmed product name. A matching product name is required even when this pattern is configured.
      Specified by:
      getDatabaseProductNamePattern in interface IDBAdapter
      Returns:
      a product-name regular expression, or null if none is needed
    • getDatabaseDriverNamePattern

      public String getDatabaseDriverNamePattern()
      Description copied from interface: IDBAdapter
      Returns an optional regular expression that constrains JDBC driver-name matching. The complete driver name must match case-insensitively; a missing driver name does not match.
      Specified by:
      getDatabaseDriverNamePattern in interface IDBAdapter
      Returns:
      a JDBC driver-name regular expression, or null if no driver constraint applies
    • getDatabaseURLPattern

      public String getDatabaseURLPattern()
      Description copied from interface: IDBAdapter
      Returns an optional regular expression that constrains JDBC URL matching. The complete URL must match case-insensitively; a missing URL does not match.
      Specified by:
      getDatabaseURLPattern in interface IDBAdapter
      Returns:
      a JDBC URL regular expression, or null if no URL constraint applies
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createConnectionProvider

      public IDBConnectionProvider createConnectionProvider(DataSource dataSource)
      Specified by:
      createConnectionProvider in interface IDBAdapter
    • modifyConnection

      public Connection modifyConnection(Connection connection)
      Specified by:
      modifyConnection in interface IDBAdapter
    • isCaseSensitive

      public boolean isCaseSensitive()
      Specified by:
      isCaseSensitive in interface IDBAdapter
    • getDefaultSchemaName

      public String getDefaultSchemaName(Connection connection)
      Specified by:
      getDefaultSchemaName in interface IDBAdapter
    • createSchema

      public void createSchema(Connection connection, String schemaName)
      Specified by:
      createSchema in interface IDBAdapter
    • openSchemaTransaction

      public IDBSchemaTransaction openSchemaTransaction(IDBDatabase database, IDBConnection currentConnection)
      Description copied from interface: IDBAdapter
      Opens a schema transaction through the adapter extension point.
      Specified by:
      openSchemaTransaction in interface IDBAdapter
    • readSchema

      public IDBSchema readSchema(Connection connection, String name)
      Specified by:
      readSchema in interface IDBAdapter
    • readSchema

      public void readSchema(Connection connection, IDBSchema schema)
      Specified by:
      readSchema in interface IDBAdapter
    • updateSchema

      public void updateSchema(Connection connection, IDBSchema schema, IDBSchemaDelta delta) throws DBException
      Specified by:
      updateSchema in interface IDBAdapter
      Throws:
      DBException
    • createTables

      public Set<IDBTable> createTables(Iterable<? extends IDBTable> tables, Connection connection) throws DBException
      Specified by:
      createTables in interface IDBAdapter
      Throws:
      DBException
    • createTable

      public boolean createTable(IDBTable table, Statement statement) throws DBException
      Specified by:
      createTable in interface IDBAdapter
      Throws:
      DBException
    • dropTables

      public Collection<IDBTable> dropTables(Iterable<? extends IDBTable> tables, Connection connection) throws DBException
      Specified by:
      dropTables in interface IDBAdapter
      Throws:
      DBException
    • dropTable

      public boolean dropTable(IDBTable table, Statement statement)
      Specified by:
      dropTable in interface IDBAdapter
    • getReservedWords

      public String[] getReservedWords()
      Specified by:
      getReservedWords in interface IDBAdapter
    • isReservedWord

      public boolean isReservedWord(String word)
      Specified by:
      isReservedWord in interface IDBAdapter
    • getMaxTableNameLength

      public int getMaxTableNameLength()
      Specified by:
      getMaxTableNameLength in interface IDBAdapter
    • getMaxFieldNameLength

      public int getMaxFieldNameLength()
      Specified by:
      getMaxFieldNameLength in interface IDBAdapter
    • getFieldLength

      public int getFieldLength(DBType type)
      Description copied from interface: IDBAdapter
      Returns the column length for the given database type.
      Specified by:
      getFieldLength in interface IDBAdapter
      Parameters:
      type - the DBType to check.
      Returns:
      the supported column length for the type.
    • isTypeIndexable

      public boolean isTypeIndexable(DBType type)
      Specified by:
      isTypeIndexable in interface IDBAdapter
    • adaptType

      public DBType adaptType(DBType type)
      Description copied from interface: IDBAdapter
      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.
      Specified by:
      adaptType in interface IDBAdapter
    • getJDBCTypeForNull

      public int getJDBCTypeForNull(DBType type)
      Description copied from interface: IDBAdapter
      Returns the JDBC type to use when binding a null value for the given database type.
      Specified by:
      getJDBCTypeForNull in interface IDBAdapter
    • useJavaTypeForUnknownParameterType

      public boolean useJavaTypeForUnknownParameterType()
      Description copied from interface: IDBAdapter
      Returns whether a Java value's type may select a specialized JDBC setter when its logical database type is unknown. If this method returns false, unknown non-null values use PreparedStatement.setObject(int, Object). If it returns true, supported scalar Java types may use their corresponding typed setter; unsupported values still use setObject. This policy does not affect parameters with an inferred database type.
      Specified by:
      useJavaTypeForUnknownParameterType in interface IDBAdapter
      Returns:
      true to use supported Java scalar types for unknown parameters; otherwise false
    • bindParameter

      public void bindParameter(PreparedStatement stmt, int index, DBType type, Object value) throws SQLException
      Description copied from interface: IDBAdapter
      Binds a converted value using the JDBC operation selected by this adapter for its logical database type and Java value type. The value may be null. Implementations may specialize compatible scalar types; values without a supported specialization use PreparedStatement.setObject(int, Object). A null value with a known type uses this adapter's IDBAdapter.getJDBCTypeForNull(DBType) mapping. A null value with an unknown type may use generic object binding. The default preserves generic binding for adapters that do not override this operation.
      Specified by:
      bindParameter in interface IDBAdapter
      Parameters:
      stmt - the prepared statement
      index - the one-based JDBC parameter index
      type - the inferred logical database type, or null if it cannot be inferred
      value - the converted Java value, possibly null
      Throws:
      SQLException - if JDBC reports a binding failure
    • isValidFirstChar

      public boolean isValidFirstChar(char ch)
      Description copied from interface: IDBAdapter
      Check if a character is valid as first character. (e.g., underscores are forbidden as first character in Derby elements.
      Specified by:
      isValidFirstChar in interface IDBAdapter
    • isDuplicateKeyException

      public boolean isDuplicateKeyException(SQLException ex)
      Description copied from interface: IDBAdapter
      Check if an exception indicates a constraint violation (duplicate key)
      Specified by:
      isDuplicateKeyException in interface IDBAdapter
    • isDuplicateKeyTransactionAbort

      public boolean isDuplicateKeyTransactionAbort()
      Description copied from interface: IDBAdapter
      Returns whether a duplicate-key exception aborts the current JDBC transaction and therefore requires a savepoint to recover from it.
      Specified by:
      isDuplicateKeyTransactionAbort in interface IDBAdapter
    • isTableNotFoundException

      public boolean isTableNotFoundException(SQLException ex)
      Specified by:
      isTableNotFoundException in interface IDBAdapter
    • isColumnNotFoundException

      public boolean isColumnNotFoundException(SQLException ex)
      Specified by:
      isColumnNotFoundException in interface IDBAdapter
    • quoteIdentifier

      public String quoteIdentifier(String identifier)
      Description copied from interface: IDBAdapter
      Quotes one SQL identifier using the adapter's identifier delimiter. Qualified names must be split into their individual components before calling this method. Quoting can be disabled globally with DBUtil.DISABLE_QUOTED_NAMES.
      Specified by:
      quoteIdentifier in interface IDBAdapter
      Parameters:
      identifier - one unqualified SQL identifier
      Returns:
      the identifier, quoted and escaped according to this adapter
    • quoteTableName

      public String quoteTableName(IDBTable table)
      Description copied from interface: IDBAdapter
      Quotes the physical name of a table for use in SQL. When the table's schema enables qualified table names, the schema and table names are quoted independently and joined with a dot. This preserves the distinction between identifier components and avoids treating the dot as part of either identifier. Each component is escaped according to this adapter's IDBAdapter.quoteIdentifier(String) implementation, and the global quoted-name compatibility setting remains in effect.
      Specified by:
      quoteTableName in interface IDBAdapter
      Parameters:
      table - the schema table to render
      Returns:
      the adapter-specific table name, including its schema when configured
    • validateSQLLiteral

      public void validateSQLLiteral(Object value)
      Description copied from interface: IDBAdapter
      Validates whether the given value can be rendered as a SQL literal by this adapter. The default implementation performs no additional validation; adapters with dialect-specific restrictions may reject values during DML compilation.
      Specified by:
      validateSQLLiteral in interface IDBAdapter
      Parameters:
      value - the Java value, possibly null
    • sqlRenameField

      public String sqlRenameField(IDBField field, String oldName)
      Specified by:
      sqlRenameField in interface IDBAdapter
    • sqlModifyField

      public String sqlModifyField(IDBField field)
      Specified by:
      sqlModifyField in interface IDBAdapter
    • sqlCharIndex

      public String sqlCharIndex(Object substring, Object string)
      Specified by:
      sqlCharIndex in interface IDBAdapter
    • sqlSubstring

      public String sqlSubstring(Object string, Object startIndex, Object length)
      Specified by:
      sqlSubstring in interface IDBAdapter
    • sqlSubstring

      public String sqlSubstring(Object string, Object startIndex)
      Specified by:
      sqlSubstring in interface IDBAdapter
    • sqlConcat

      public String sqlConcat(Object... strings)
      Specified by:
      sqlConcat in interface IDBAdapter
    • convertString

      public String convertString(PreparedStatement preparedStatement, int parameterIndex, String value)
      Description copied from interface: IDBAdapter
      Converts a string before it is bound to a prepared statement.
      Specified by:
      convertString in interface IDBAdapter
    • convertString

      public String convertString(ResultSet resultSet, int columnIndex, String value)
      Description copied from interface: IDBAdapter
      Converts a string read from a result-set column.
      Specified by:
      convertString in interface IDBAdapter
    • convertString

      public String convertString(ResultSet resultSet, String columnLabel, String value)
      Description copied from interface: IDBAdapter
      Converts a string read from a named result-set column.
      Specified by:
      convertString in interface IDBAdapter
    • getSQL92ReservedWords

      public String[] getSQL92ReservedWords()
      Description copied from interface: IDBAdapter
      Returns the SQL-92 reserved words used by the adapter implementation.
      Specified by:
      getSQL92ReservedWords in interface IDBAdapter
    • appendFieldNames

      public void appendFieldNames(Appendable appendable, IDBTable table)
      Description copied from interface: IDBAdapter
      Appends the field names used by the adapter's table SQL generation.
      Specified by:
      appendFieldNames in interface IDBAdapter
    • format

      public String format(PreparedStatement stmt)
      Description copied from interface: IDBAdapter
      Formats a prepared statement for diagnostic output.
      Specified by:
      format in interface IDBAdapter
    • format

      public String format(ResultSet resultSet)
      Description copied from interface: IDBAdapter
      Formats a result set for diagnostic output.
      Specified by:
      format in interface IDBAdapter
    • convertToSQL

      public Object convertToSQL(Object value)
      Description copied from interface: IDBAdapter
      Converts a Java value to the value used by SQL query execution.
      Specified by:
      convertToSQL in interface IDBAdapter
    • getJDBCDriver

      @Deprecated public Driver getJDBCDriver()
      Deprecated.
      Specified by:
      getJDBCDriver in interface IDBAdapter
    • createJDBCDataSource

      @Deprecated public DataSource createJDBCDataSource()
      Deprecated.
      Specified by:
      createJDBCDataSource in interface IDBAdapter