Package org.eclipse.net4j.spi.db
Class DelegatingDBAdapter
java.lang.Object
org.eclipse.net4j.spi.db.DelegatingDBAdapter
- All Implemented Interfaces:
IDBAdapter,IDBAdapterID
Keeps extension metadata authoritative without requiring the created adapter to extend DBAdapter.
- Since:
- 4.14
- Author:
- Eike Stepper
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.net4j.db.IDBAdapter
IDBAdapter.Registry -
Field Summary
Fields inherited from interface org.eclipse.net4j.db.IDBAdapter
REGISTRY -
Constructor Summary
ConstructorsConstructorDescriptionDelegatingDBAdapter(IDBAdapter delegate) DelegatingDBAdapter(IDBAdapter delegate, String name, String version) -
Method Summary
Modifier and TypeMethodDescriptionProvide a way for the DBAdapter to override unsupported DB types with replacements.voidappendFieldNames(Appendable appendable, IDBTable table) Appends the field names used by the adapter's table SQL generation.voidbindParameter(PreparedStatement stmt, int index, DBType type, Object value) Binds a converted value using the JDBC operation selected by this adapter for its logical database type and Java value type.convertString(PreparedStatement preparedStatement, int parameterIndex, String value) Converts a string before it is bound to a prepared statement.convertString(ResultSet resultSet, int columnIndex, String value) Converts a string read from a result-set column.convertString(ResultSet resultSet, String columnLabel, String value) Converts a string read from a named result-set column.convertToSQL(Object value) Converts a Java value to the value used by SQL query execution.createConnectionProvider(DataSource dataSource) Deprecated.voidcreateSchema(Connection connection, String schemaName) booleancreateTable(IDBTable table, Statement statement) createTables(Iterable<? extends IDBTable> tables, Connection connection) booleandropTables(Iterable<? extends IDBTable> tables, Connection connection) booleanformat(PreparedStatement stmt) Formats a prepared statement for diagnostic output.Formats a result set for diagnostic output.Returns an optional regular expression that constrains JDBC driver-name matching.Returns an optional regular expression for additional JDBC product-name matching.String[]Returns the JDBC database product names recognized by this adapter.Returns an optional regular expression that constrains JDBC URL matching.getDefaultSchemaName(Connection connection) intgetFieldLength(DBType type) Returns the column length for the given database type.Deprecated.intgetJDBCTypeForNull(DBType type) Returns the JDBC type to use when binding a null value for the given database type.intintgetName()Returns the provider's adapter name.String[]String[]Returns the SQL-92 reserved words used by the adapter implementation.Returns the provider's adapter version.inthashCode()booleanbooleanbooleanCheck if an exception indicates a constraint violation (duplicate key)booleanReturns whether a duplicate-key exception aborts the current JDBC transaction and therefore requires a savepoint to recover from it.booleanisReservedWord(String word) booleanbooleanisTypeIndexable(DBType type) booleanisValidFirstChar(char ch) Check if a character is valid as first character.modifyConnection(Connection connection) openSchemaTransaction(IDBDatabase database, IDBConnection currentConnection) Opens a schema transaction through the adapter extension point.quoteIdentifier(String identifier) Quotes one SQL identifier using the adapter's identifier delimiter.quoteTableName(IDBTable table) Quotes the physical name of a table for use in SQL.readSchema(Connection connection, String name) voidreadSchema(Connection connection, IDBSchema schema) sqlCharIndex(Object substring, Object string) sqlModifyField(IDBField field) sqlRenameField(IDBField field, String oldName) sqlSubstring(Object string, Object startIndex) sqlSubstring(Object string, Object startIndex, Object length) toString()voidupdateSchema(Connection connection, IDBSchema schema, IDBSchemaDelta delta) booleanReturns whether a Java value's type may select a specialized JDBC setter when its logical database type is unknown.voidvalidateSQLLiteral(Object value) Validates whether the given value can be rendered as a SQL literal by this adapter.
-
Constructor Details
-
DelegatingDBAdapter
-
DelegatingDBAdapter
-
-
Method Details
-
getName
Description copied from interface:IDBAdapterReturns 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:
getNamein interfaceIDBAdapter- Specified by:
getNamein interfaceIDBAdapterID- Returns:
- the adapter name
-
getVersion
Description copied from interface:IDBAdapterReturns 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:
getVersionin interfaceIDBAdapter- Specified by:
getVersionin interfaceIDBAdapterID- Returns:
- the adapter version
-
getDatabaseProductNames
Description copied from interface:IDBAdapterReturns 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:
getDatabaseProductNamesin interfaceIDBAdapter- Returns:
- the exact JDBC product names recognized by this adapter
-
getDatabaseProductNamePattern
Description copied from interface:IDBAdapterReturns 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:
getDatabaseProductNamePatternin interfaceIDBAdapter- Returns:
- a product-name regular expression, or
nullif none is needed
-
getDatabaseDriverNamePattern
Description copied from interface:IDBAdapterReturns 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:
getDatabaseDriverNamePatternin interfaceIDBAdapter- Returns:
- a JDBC driver-name regular expression, or
nullif no driver constraint applies
-
getDatabaseURLPattern
Description copied from interface:IDBAdapterReturns an optional regular expression that constrains JDBC URL matching. The complete URL must match case-insensitively; a missing URL does not match.- Specified by:
getDatabaseURLPatternin interfaceIDBAdapter- Returns:
- a JDBC URL regular expression, or
nullif no URL constraint applies
-
hashCode
public int hashCode() -
equals
-
toString
-
createConnectionProvider
- Specified by:
createConnectionProviderin interfaceIDBAdapter
-
modifyConnection
- Specified by:
modifyConnectionin interfaceIDBAdapter
-
isCaseSensitive
public boolean isCaseSensitive()- Specified by:
isCaseSensitivein interfaceIDBAdapter
-
getDefaultSchemaName
- Specified by:
getDefaultSchemaNamein interfaceIDBAdapter
-
createSchema
- Specified by:
createSchemain interfaceIDBAdapter
-
openSchemaTransaction
public IDBSchemaTransaction openSchemaTransaction(IDBDatabase database, IDBConnection currentConnection) Description copied from interface:IDBAdapterOpens a schema transaction through the adapter extension point.- Specified by:
openSchemaTransactionin interfaceIDBAdapter
-
readSchema
- Specified by:
readSchemain interfaceIDBAdapter
-
readSchema
- Specified by:
readSchemain interfaceIDBAdapter
-
updateSchema
public void updateSchema(Connection connection, IDBSchema schema, IDBSchemaDelta delta) throws DBException - Specified by:
updateSchemain interfaceIDBAdapter- Throws:
DBException
-
createTables
public Set<IDBTable> createTables(Iterable<? extends IDBTable> tables, Connection connection) throws DBException - Specified by:
createTablesin interfaceIDBAdapter- Throws:
DBException
-
createTable
- Specified by:
createTablein interfaceIDBAdapter- Throws:
DBException
-
dropTables
public Collection<IDBTable> dropTables(Iterable<? extends IDBTable> tables, Connection connection) throws DBException - Specified by:
dropTablesin interfaceIDBAdapter- Throws:
DBException
-
dropTable
- Specified by:
dropTablein interfaceIDBAdapter
-
getReservedWords
- Specified by:
getReservedWordsin interfaceIDBAdapter
-
isReservedWord
- Specified by:
isReservedWordin interfaceIDBAdapter
-
getMaxTableNameLength
public int getMaxTableNameLength()- Specified by:
getMaxTableNameLengthin interfaceIDBAdapter
-
getMaxFieldNameLength
public int getMaxFieldNameLength()- Specified by:
getMaxFieldNameLengthin interfaceIDBAdapter
-
getFieldLength
Description copied from interface:IDBAdapterReturns the column length for the given database type.- Specified by:
getFieldLengthin interfaceIDBAdapter- Parameters:
type- theDBTypeto check.- Returns:
- the supported column length for the type.
-
isTypeIndexable
- Specified by:
isTypeIndexablein interfaceIDBAdapter
-
adaptType
Description copied from interface:IDBAdapterProvide 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:
adaptTypein interfaceIDBAdapter
-
getJDBCTypeForNull
Description copied from interface:IDBAdapterReturns the JDBC type to use when binding a null value for the given database type.- Specified by:
getJDBCTypeForNullin interfaceIDBAdapter
-
useJavaTypeForUnknownParameterType
public boolean useJavaTypeForUnknownParameterType()Description copied from interface:IDBAdapterReturns whether a Java value's type may select a specialized JDBC setter when its logical database type is unknown. If this method returnsfalse, unknown non-null values usePreparedStatement.setObject(int, Object). If it returnstrue, supported scalar Java types may use their corresponding typed setter; unsupported values still usesetObject. This policy does not affect parameters with an inferred database type.- Specified by:
useJavaTypeForUnknownParameterTypein interfaceIDBAdapter- Returns:
trueto use supported Java scalar types for unknown parameters; otherwisefalse
-
bindParameter
public void bindParameter(PreparedStatement stmt, int index, DBType type, Object value) throws SQLException Description copied from interface:IDBAdapterBinds a converted value using the JDBC operation selected by this adapter for its logical database type and Java value type. The value may benull. Implementations may specialize compatible scalar types; values without a supported specialization usePreparedStatement.setObject(int, Object). A null value with a known type uses this adapter'sIDBAdapter.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:
bindParameterin interfaceIDBAdapter- Parameters:
stmt- the prepared statementindex- the one-based JDBC parameter indextype- the inferred logical database type, ornullif it cannot be inferredvalue- the converted Java value, possiblynull- Throws:
SQLException- if JDBC reports a binding failure
-
isValidFirstChar
public boolean isValidFirstChar(char ch) Description copied from interface:IDBAdapterCheck if a character is valid as first character. (e.g., underscores are forbidden as first character in Derby elements.- Specified by:
isValidFirstCharin interfaceIDBAdapter
-
isDuplicateKeyException
Description copied from interface:IDBAdapterCheck if an exception indicates a constraint violation (duplicate key)- Specified by:
isDuplicateKeyExceptionin interfaceIDBAdapter
-
isDuplicateKeyTransactionAbort
public boolean isDuplicateKeyTransactionAbort()Description copied from interface:IDBAdapterReturns whether a duplicate-key exception aborts the current JDBC transaction and therefore requires a savepoint to recover from it.- Specified by:
isDuplicateKeyTransactionAbortin interfaceIDBAdapter
-
isTableNotFoundException
- Specified by:
isTableNotFoundExceptionin interfaceIDBAdapter
-
isColumnNotFoundException
- Specified by:
isColumnNotFoundExceptionin interfaceIDBAdapter
-
quoteIdentifier
Description copied from interface:IDBAdapterQuotes 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 withDBUtil.DISABLE_QUOTED_NAMES.- Specified by:
quoteIdentifierin interfaceIDBAdapter- Parameters:
identifier- one unqualified SQL identifier- Returns:
- the identifier, quoted and escaped according to this adapter
-
quoteTableName
Description copied from interface:IDBAdapterQuotes 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'sIDBAdapter.quoteIdentifier(String)implementation, and the global quoted-name compatibility setting remains in effect.- Specified by:
quoteTableNamein interfaceIDBAdapter- Parameters:
table- the schema table to render- Returns:
- the adapter-specific table name, including its schema when configured
-
validateSQLLiteral
Description copied from interface:IDBAdapterValidates 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:
validateSQLLiteralin interfaceIDBAdapter- Parameters:
value- the Java value, possiblynull
-
sqlRenameField
- Specified by:
sqlRenameFieldin interfaceIDBAdapter
-
sqlModifyField
- Specified by:
sqlModifyFieldin interfaceIDBAdapter
-
sqlCharIndex
- Specified by:
sqlCharIndexin interfaceIDBAdapter
-
sqlSubstring
- Specified by:
sqlSubstringin interfaceIDBAdapter
-
sqlSubstring
- Specified by:
sqlSubstringin interfaceIDBAdapter
-
sqlConcat
- Specified by:
sqlConcatin interfaceIDBAdapter
-
convertString
Description copied from interface:IDBAdapterConverts a string before it is bound to a prepared statement.- Specified by:
convertStringin interfaceIDBAdapter
-
convertString
Description copied from interface:IDBAdapterConverts a string read from a result-set column.- Specified by:
convertStringin interfaceIDBAdapter
-
convertString
Description copied from interface:IDBAdapterConverts a string read from a named result-set column.- Specified by:
convertStringin interfaceIDBAdapter
-
getSQL92ReservedWords
Description copied from interface:IDBAdapterReturns the SQL-92 reserved words used by the adapter implementation.- Specified by:
getSQL92ReservedWordsin interfaceIDBAdapter
-
appendFieldNames
Description copied from interface:IDBAdapterAppends the field names used by the adapter's table SQL generation.- Specified by:
appendFieldNamesin interfaceIDBAdapter
-
format
Description copied from interface:IDBAdapterFormats a prepared statement for diagnostic output.- Specified by:
formatin interfaceIDBAdapter
-
format
Description copied from interface:IDBAdapterFormats a result set for diagnostic output.- Specified by:
formatin interfaceIDBAdapter
-
convertToSQL
Description copied from interface:IDBAdapterConverts a Java value to the value used by SQL query execution.- Specified by:
convertToSQLin interfaceIDBAdapter
-
getJDBCDriver
Deprecated.- Specified by:
getJDBCDriverin interfaceIDBAdapter
-
createJDBCDataSource
Deprecated.- Specified by:
createJDBCDataSourcein interfaceIDBAdapter
-