Package org.eclipse.net4j.spi.db

# 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

## 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

Constructors
Constructor
Description
`DelegatingDBAdapter(IDBAdapter delegate)`
`DelegatingDBAdapter(IDBAdapter delegate, String name, String version)`

## Method Summary

Modifier and Type
Method
Description
`DBType`
`adaptType(DBType type)`
Provide a way for the DBAdapter to override unsupported DB types with replacements.
`void`
`appendFieldNames(Appendable appendable, IDBTable table)`
Appends the field names used by the adapter's table SQL generation.
`String`
`convertString(PreparedStatement preparedStatement, int parameterIndex, String value)`
Converts a string before it is bound to a prepared statement.
`String`
`convertString(ResultSet resultSet, int columnIndex, String value)`
Converts a string read from a result-set column.
`String`
`convertString(ResultSet resultSet, String columnLabel, String value)`
Converts a string read from a named result-set column.
`Object`
`convertToSQL(Object value)`
Converts a Java value to the value used by SQL query execution.
`IDBConnectionProvider`
`createConnectionProvider(DataSource dataSource)`
`DataSource`
`createJDBCDataSource()`
Deprecated.
`void`
`createSchema(Connection connection, String schemaName)`
`boolean`
`createTable(IDBTable table, Statement statement)`
`Set<IDBTable>`
`createTables(Iterable<? extends IDBTable> tables, Connection connection)`
`boolean`
`dropTable(IDBTable table, Statement statement)`
`Collection<IDBTable>`
`dropTables(Iterable<? extends IDBTable> tables, Connection connection)`
`boolean`
`equals(Object obj)`
`String`
`format(PreparedStatement stmt)`
Formats a prepared statement for diagnostic output.
`String`
`format(ResultSet resultSet)`
Formats a result set for diagnostic output.
`String`
`getDefaultSchemaName(Connection connection)`
`int`
`getFieldLength(DBType type)`
Returns the column length for the given database type.
`Driver`
`getJDBCDriver()`
Deprecated.
`int`
`getJDBCTypeForNull(DBType type)`
Returns the JDBC type to use when binding a null value for the given database type.
`int`
`getMaxFieldNameLength()`
`int`
`getMaxTableNameLength()`
`String`
`getName()`
Returns the provider's adapter name.
`String[]`
`getReservedWords()`
`String[]`
`getSQL92ReservedWords()`
Returns the SQL-92 reserved words used by the adapter implementation.
`String`
`getVersion()`
Returns the provider's adapter version.
`int`
`hashCode()`
`boolean`
`isCaseSensitive()`
`boolean`
`isColumnNotFoundException(SQLException ex)`
`boolean`
`isDuplicateKeyException(SQLException ex)`
Check if an exception indicates a constraint violation (duplicate key)
`boolean`
`isDuplicateKeyTransactionAbort()`
Returns whether a duplicate-key exception aborts the current JDBC transaction and therefore requires a savepoint to recover from it.
`boolean`
`isReservedWord(String word)`
`boolean`
`isTableNotFoundException(SQLException ex)`
`boolean`
`isTypeIndexable(DBType type)`
`boolean`
`isValidFirstChar(char ch)`
Check if a character is valid as first character.
`Connection`
`modifyConnection(Connection connection)`
`IDBSchemaTransaction`
`openSchemaTransaction(IDBDatabase database, IDBConnection currentConnection)`
Opens a schema transaction through the adapter extension point.
`IDBSchema`
`readSchema(Connection connection, String name)`
`void`
`readSchema(Connection connection, IDBSchema schema)`
`String`
`sqlCharIndex(Object substring, Object string)`
`String`
`sqlConcat(Object... strings)`
`String`
`sqlModifyField(IDBField field)`
`String`
`sqlRenameField(IDBField field, String oldName)`
`String`
`sqlSubstring(Object string, Object startIndex)`
`String`
`sqlSubstring(Object string, Object startIndex, Object length)`
`String`
`toString()`
`void`
`updateSchema(Connection connection, IDBSchema schema, IDBSchemaDelta delta)`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## 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

### 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`

### 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`

### 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`