Package org.eclipse.net4j.spi.db

# Klasse DBAdapter

java.lang.Object
org.eclipse.net4j.spi.db.DBAdapter

Alle implementierten Schnittstellen:
  `IDBAdapter`

Bekannte direkte Unterklassen:
  `DerbyAdapter`, `H2Adapter`, `HSQLDBAdapter`, `MYSQLAdapter`, `PostgreSQLAdapter`

public abstract class DBAdapter extends Object implements IDBAdapter
A useful base class for implementing custom `DB adapters`.

Autor:
  Eike Stepper

## Verschachtelte Klassen - Übersicht

Verschachtelte Klassen
Modifizierer und Typ
Klasse
Beschreibung
`protected static final class`
`DBAdapter.FieldInfo`

## Feldübersicht

### Von Schnittstelle geerbte Felder org.eclipse.net4j.db.IDBAdapter

`REGISTRY`

## Konstruktorübersicht

Konstruktoren
Konstruktor
Beschreibung
`DBAdapter(String name, String version)`

## Methodenübersicht

Modifizierer und Typ
Methode
Beschreibung
`DBType`
`adaptType(DBType type)`
Provide a way for the DBAdapter to override unsupported DB types with replacements.
`protected void`
`addIndex(Connection connection, IDBTable table, String name, IDBIndex.Type type, List<DBAdapter.FieldInfo> fieldInfos)`
`protected void`
`addIndexField(StringBuilder builder, IDBField field)`
`protected void`
`alterTable(Connection connection, IDBTable table, IDBTableDelta delta)`
`protected void`
`appendFieldDefs(Appendable appendable, IDBTable table, String[] defs)`
`void`
`appendFieldNames(Appendable appendable, IDBTable table)`
`String`
`convertString(PreparedStatement preparedStatement, int parameterIndex, String value)`
`String`
`convertString(ResultSet resultSet, int columnIndex, String value)`
`String`
`convertString(ResultSet resultSet, String columnLabel, String value)`
`Object`
`convertToSQL(Object value)`
`IDBConnectionProvider`
`createConnectionProvider(DataSource dataSource)`
`protected String`
`createConstraints(IDBTable table)`
`protected void`
`createField(Connection connection, String tableName, IDBField field)`
`protected String`
`createFieldDefinition(IDBField field)`
`protected String[]`
`createFieldDefinitions(IDBTable table)`
`protected void`
`createIndex(Connection connection, IDBIndex index, IDBIndexDelta delta)`
`protected void`
`createIndex(IDBIndex index, StringBuilder builder)`
`protected void`
`createIndex(IDBIndex index, Statement statement, int num)`
`protected void`
`createIndexFields(IDBIndex index, StringBuilder builder)`
`DataSource`
`createJDBCDataSource()`
Veraltet.
As of 4.2 no longer supported because of IP issues for external build dependencies (the vendor driver libs).
`protected void`
`createPrimaryKey(IDBIndex index, StringBuilder builder)`
`void`
`createSchema(Connection connection, String schemaName)`
`protected void`
`createTable(Connection connection, IDBTable table, IDBTableDelta delta)`
`boolean`
`createTable(IDBTable table, Statement statement)`
`Set<IDBTable>`
`createTables(Iterable<? extends IDBTable> tables, Connection connection)`
`protected void`
`doCreateTable(IDBTable table, Statement statement)`
`protected void`
`dropField(Connection connection, String tableName, String fieldName)`
`protected void`
`dropIndex(Connection connection, IDBIndex index, IDBIndexDelta delta)`
`protected void`
`dropIndex(IDBIndex index, StringBuilder builder)`
`protected void`
`dropPrimaryKey(IDBIndex index, StringBuilder builder)`
`protected void`
`dropTable(Connection connection, IDBTable table, IDBTableDelta delta)`
`boolean`
`dropTable(IDBTable table, Statement statement)`
`Collection<IDBTable>`
`dropTables(Iterable<? extends IDBTable> tables, Connection connection)`
`String`
`format(PreparedStatement stmt)`
`String`
`format(ResultSet resultSet)`
`protected static void`
`generateReservedWords(Connection connection, String[] words)`
`static int`
`getDefaultDBLength(DBType type)`
`String`
`getDefaultSchemaName(Connection connection)`
`protected String`
`getDropTableSQL(IDBTable table)`
`int`
`getFieldLength(DBType type)`
Returns the column length for the given database type.
`Driver`
`getJDBCDriver()`
Veraltet.
As of 4.2 no longer supported because of IP issues for external build dependencies (the vendor driver libs).
`int`
`getMaxFieldNameLength()`
`int`
`getMaxTableNameLength()`
`String`
`getName()`
`protected String`
`getNullableConstraint()`
`String[]`
`getSQL92ReservedWords()`
`protected String`
`getTypeName(IDBField field)`
`String`
`getVersion()`
`boolean`
`isCaseSensitive()`
`boolean`
`isColumnNotFoundException(SQLException ex)`
`boolean`
`isDuplicateKeyException(SQLException ex)`
Check if an exception indicates a constraint violation (duplicate key)
`protected boolean`
`isPrimaryKeyShadow(Connection connection, IDBTable table, String name, IDBIndex.Type type, IDBField[] fields)`
`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)`
`protected void`
`readFields(Connection connection, IDBTable table)`
`protected void`
`readIndices(Connection connection, DatabaseMetaData metaData, IDBTable table, String schemaName)`
`protected void`
`readIndices(Connection connection, ResultSet resultSet, IDBTable table, int indexNameColumn, int indexTypeColumn, int fieldNameColumn, int fieldPositionColumn)`
`IDBSchema`
`readSchema(Connection connection, String name)`
`void`
`readSchema(Connection connection, IDBSchema schema)`
`protected ResultSet`
`readTables(Connection connection, DatabaseMetaData metaData, String schemaName)`
`protected String`
`sqlModifyField(String tableName, String fieldName, String definition)`
`String`
`sqlModifyField(IDBField field)`
`String`
`sqlRenameField(IDBField field, String oldName)`
`String`
`toString()`
`void`
`updateSchema(Connection connection, IDBSchema schema, IDBSchemaDelta delta)`
`protected void`
`validateTable(IDBTable table, Statement statement)`

### Von Klasse geerbte Methoden java.lang.Object

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

### Von Schnittstelle geerbte Methoden org.eclipse.net4j.db.IDBAdapter

`getReservedWords`

## Konstruktordetails

### DBAdapter

public DBAdapter(String name, String version)

## Methodendetails

### getName

public String getName()

Angegeben von:
  `getName` in Schnittstelle `IDBAdapter`

### getVersion

public String getVersion()

Angegeben von:
  `getVersion` in Schnittstelle `IDBAdapter`

### isCaseSensitive

public boolean isCaseSensitive()

Angegeben von:
  `isCaseSensitive` in Schnittstelle `IDBAdapter`

### getDefaultSchemaName

public String getDefaultSchemaName(Connection connection)

Angegeben von:
  `getDefaultSchemaName` in Schnittstelle `IDBAdapter`

### createConnectionProvider

public IDBConnectionProvider createConnectionProvider(DataSource dataSource)

Angegeben von:
  `createConnectionProvider` in Schnittstelle `IDBAdapter`
Seit:
  4.3

### modifyConnection

public Connection modifyConnection(Connection connection)

Angegeben von:
  `modifyConnection` in Schnittstelle `IDBAdapter`
Seit:
  4.5

### createSchema

public void createSchema(Connection connection, String schemaName)

Angegeben von:
  `createSchema` in Schnittstelle `IDBAdapter`

### openSchemaTransaction

public IDBSchemaTransaction openSchemaTransaction(IDBDatabase database, IDBConnection currentConnection)

Seit:
  4.9

### readSchema

public IDBSchema readSchema(Connection connection, String name)

Angegeben von:
  `readSchema` in Schnittstelle `IDBAdapter`
Seit:
  4.2

### readSchema

public void readSchema(Connection connection, IDBSchema schema)

Angegeben von:
  `readSchema` in Schnittstelle `IDBAdapter`
Seit:
  4.2

### readTables

protected ResultSet readTables(Connection connection, DatabaseMetaData metaData, String schemaName) throws SQLException

Löst aus:
  `SQLException`
Seit:
  4.3

### readFields

protected void readFields(Connection connection, IDBTable table) throws SQLException

Löst aus:
  `SQLException`
Seit:
  4.2

### readIndices

protected void readIndices(Connection connection, DatabaseMetaData metaData, IDBTable table, String schemaName) throws SQLException

Löst aus:
  `SQLException`
Seit:
  4.2

### readIndices

protected void readIndices(Connection connection, ResultSet resultSet, IDBTable table, int indexNameColumn, int indexTypeColumn, int fieldNameColumn, int fieldPositionColumn) throws SQLException

Löst aus:
  `SQLException`
Seit:
  4.2

### addIndex

protected void addIndex(Connection connection, IDBTable table, String name, IDBIndex.Type type, List<DBAdapter.FieldInfo> fieldInfos)

Seit:
  4.2

### isPrimaryKeyShadow

protected boolean isPrimaryKeyShadow(Connection connection, IDBTable table, String name, IDBIndex.Type type, IDBField[] fields)

Seit:
  4.2

### updateSchema

public void updateSchema(Connection connection, IDBSchema schema, IDBSchemaDelta delta) throws DBException

Angegeben von:
  `updateSchema` in Schnittstelle `IDBAdapter`
Löst aus:
  `DBException`
Seit:
  4.2

### createTable

protected void createTable(Connection connection, IDBTable table, IDBTableDelta delta)

Seit:
  4.2

### dropTable

protected void dropTable(Connection connection, IDBTable table, IDBTableDelta delta)

Seit:
  4.2

### alterTable

protected void alterTable(Connection connection, IDBTable table, IDBTableDelta delta)

Seit:
  4.2

### createField

protected void createField(Connection connection, String tableName, IDBField field)

Seit:
  4.6

### dropField

protected void dropField(Connection connection, String tableName, String fieldName)

Seit:
  4.6

### createIndex

protected void createIndex(Connection connection, IDBIndex index, IDBIndexDelta delta)

Seit:
  4.2

### createPrimaryKey

protected void createPrimaryKey(IDBIndex index, StringBuilder builder)

Seit:
  4.2

### createIndex

protected void createIndex(IDBIndex index, StringBuilder builder)

Seit:
  4.2

### createIndexFields

protected void createIndexFields(IDBIndex index, StringBuilder builder)

Seit:
  4.2

### dropIndex

protected void dropIndex(Connection connection, IDBIndex index, IDBIndexDelta delta)

Seit:
  4.2

### dropPrimaryKey

protected void dropPrimaryKey(IDBIndex index, StringBuilder builder)

Seit:
  4.2

### dropIndex

protected void dropIndex(IDBIndex index, StringBuilder builder)

Seit:
  4.2

### createTables

public Set<IDBTable> createTables(Iterable<? extends IDBTable> tables, Connection connection) throws DBException

Angegeben von:
  `createTables` in Schnittstelle `IDBAdapter`
Löst aus:
  `DBException`

### createTable

public boolean createTable(IDBTable table, Statement statement) throws DBException

Angegeben von:
  `createTable` in Schnittstelle `IDBAdapter`
Löst aus:
  `DBException`

### dropTables

public Collection<IDBTable> dropTables(Iterable<? extends IDBTable> tables, Connection connection) throws DBException

Angegeben von:
  `dropTables` in Schnittstelle `IDBAdapter`
Löst aus:
  `DBException`

### dropTable

public boolean dropTable(IDBTable table, Statement statement)

Angegeben von:
  `dropTable` in Schnittstelle `IDBAdapter`

### getDropTableSQL

protected String getDropTableSQL(IDBTable table)

### getMaxTableNameLength

public int getMaxTableNameLength()

Angegeben von:
  `getMaxTableNameLength` in Schnittstelle `IDBAdapter`
Seit:
  2.0

### getMaxFieldNameLength

public int getMaxFieldNameLength()

Angegeben von:
  `getMaxFieldNameLength` in Schnittstelle `IDBAdapter`
Seit:
  2.0

### getFieldLength

public int getFieldLength(DBType type)
Beschreibung aus Schnittstelle kopiert: `IDBAdapter`
Returns the column length for the given database type.

Angegeben von:
  `getFieldLength` in Schnittstelle `IDBAdapter`
Parameter:
  `type` - the `DBType` to check.
Gibt zurück:
  the supported column length for the type.
Seit:
  4.2

### isTypeIndexable

public boolean isTypeIndexable(DBType type)

Angegeben von:
  `isTypeIndexable` in Schnittstelle `IDBAdapter`

### toString

public String toString()

Setzt außer Kraft:
  `toString` in Klasse `Object`

### convertString

public String convertString(PreparedStatement preparedStatement, int parameterIndex, String value)

Seit:
  4.3

### convertString

public String convertString(ResultSet resultSet, int columnIndex, String value)

Seit:
  4.3

### convertString

public String convertString(ResultSet resultSet, String columnLabel, String value)

Seit:
  4.3

### doCreateTable

protected void doCreateTable(IDBTable table, Statement statement) throws SQLException

Löst aus:
  `SQLException`
Seit:
  2.0

### createIndex

protected void createIndex(IDBIndex index, Statement statement, int num) throws SQLException

Löst aus:
  `SQLException`
Seit:
  2.0

### addIndexField

protected void addIndexField(StringBuilder builder, IDBField field)

### createConstraints

protected String createConstraints(IDBTable table)

Seit:
  2.0

### createFieldDefinition

protected String createFieldDefinition(IDBField field)

Seit:
  2.0

### getNullableConstraint

protected String getNullableConstraint()

Seit:
  4.12

### getTypeName

protected String getTypeName(IDBField field)

### getSQL92ReservedWords

public String[] getSQL92ReservedWords()

### isReservedWord

public boolean isReservedWord(String word)

Angegeben von:
  `isReservedWord` in Schnittstelle `IDBAdapter`

### validateTable

protected void validateTable(IDBTable table, Statement statement) throws DBException

Löst aus:
  `DBException`
Seit:
  2.0

### createFieldDefinitions

protected String[] createFieldDefinitions(IDBTable table)

Seit:
  4.2

### appendFieldNames

public void appendFieldNames(Appendable appendable, IDBTable table)

### appendFieldDefs

protected void appendFieldDefs(Appendable appendable, IDBTable table, String[] defs)

Seit:
  4.2

### adaptType

public DBType adaptType(DBType type)
Beschreibung aus Schnittstelle kopiert: `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.

Angegeben von:
  `adaptType` in Schnittstelle `IDBAdapter`
Seit:
  3.0

### isValidFirstChar

public boolean isValidFirstChar(char ch)
Beschreibung aus Schnittstelle kopiert: `IDBAdapter`
Check if a character is valid as first character. (e.g., underscores are forbidden as first character in Derby elements.

Angegeben von:
  `isValidFirstChar` in Schnittstelle `IDBAdapter`
Seit:
  4.0

### isDuplicateKeyException

public boolean isDuplicateKeyException(SQLException ex)
Beschreibung aus Schnittstelle kopiert: `IDBAdapter`
Check if an exception indicates a constraint violation (duplicate key)

Angegeben von:
  `isDuplicateKeyException` in Schnittstelle `IDBAdapter`
Seit:
  4.0

### isTableNotFoundException

public boolean isTableNotFoundException(SQLException ex)

Angegeben von:
  `isTableNotFoundException` in Schnittstelle `IDBAdapter`
Seit:
  4.2

### isColumnNotFoundException

public boolean isColumnNotFoundException(SQLException ex)

Angegeben von:
  `isColumnNotFoundException` in Schnittstelle `IDBAdapter`
Seit:
  4.2

### sqlRenameField

public String sqlRenameField(IDBField field, String oldName)

Angegeben von:
  `sqlRenameField` in Schnittstelle `IDBAdapter`
Seit:
  4.2

### sqlModifyField

public String sqlModifyField(IDBField field)

Angegeben von:
  `sqlModifyField` in Schnittstelle `IDBAdapter`
Seit:
  4.2

### sqlModifyField

protected String sqlModifyField(String tableName, String fieldName, String definition)

Seit:
  4.2

### format

public String format(PreparedStatement stmt)

Seit:
  4.2

### format

public String format(ResultSet resultSet)

Seit:
  4.2

### convertToSQL

public Object convertToSQL(Object value)

Seit:
  4.9

### getDefaultDBLength

public static int getDefaultDBLength(DBType type)

Seit:
  4.2

### generateReservedWords

protected static void generateReservedWords(Connection connection, String[] words) throws SQLException

Löst aus:
  `SQLException`
Seit:
  4.9

### getJDBCDriver

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

Angegeben von:
  `getJDBCDriver` in Schnittstelle `IDBAdapter`
Seit:
  4.2

### createJDBCDataSource

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

Angegeben von:
  `createJDBCDataSource` in Schnittstelle `IDBAdapter`
Seit:
  4.2