Package org.eclipse.net4j.spi.db
Class DBAdapter
- java.lang.Object
- 
- org.eclipse.net4j.spi.db.DBAdapter
 
- 
- All Implemented Interfaces:
- IDBAdapter
 - Direct Known Subclasses:
- DerbyAdapter,- H2Adapter,- HSQLDBAdapter,- MYSQLAdapter,- PostgreSQLAdapter
 
 public abstract class DBAdapter extends java.lang.Object implements IDBAdapter A useful base class for implementing customDB adapters.- Author:
- Eike Stepper
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classDBAdapter.FieldInfo
 - 
Field Summary- 
Fields inherited from interface org.eclipse.net4j.db.IDBAdapterREGISTRY
 
- 
 - 
Constructor SummaryConstructors Constructor Description DBAdapter(java.lang.String name, java.lang.String version)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DBTypeadaptType(DBType type)Provide a way for the DBAdapter to override unsupported DB types with replacements.protected voidaddIndex(java.sql.Connection connection, IDBTable table, java.lang.String name, IDBIndex.Type type, java.util.List<DBAdapter.FieldInfo> fieldInfos)protected voidaddIndexField(java.lang.StringBuilder builder, IDBField field)protected voidalterTable(java.sql.Connection connection, IDBTable table, IDBTableDelta delta)protected voidappendFieldDefs(java.lang.Appendable appendable, IDBTable table, java.lang.String[] defs)voidappendFieldNames(java.lang.Appendable appendable, IDBTable table)java.lang.StringconvertString(java.sql.PreparedStatement preparedStatement, int parameterIndex, java.lang.String value)java.lang.StringconvertString(java.sql.ResultSet resultSet, int columnIndex, java.lang.String value)java.lang.StringconvertString(java.sql.ResultSet resultSet, java.lang.String columnLabel, java.lang.String value)java.lang.ObjectconvertToSQL(java.lang.Object value)IDBConnectionProvidercreateConnectionProvider(javax.sql.DataSource dataSource)protected java.lang.StringcreateConstraints(IDBTable table)protected voidcreateField(java.sql.Connection connection, java.lang.String tableName, IDBField field)protected java.lang.StringcreateFieldDefinition(IDBField field)protected java.lang.String[]createFieldDefinitions(IDBTable table)protected voidcreateIndex(java.sql.Connection connection, IDBIndex index, IDBIndexDelta delta)protected voidcreateIndex(IDBIndex index, java.lang.StringBuilder builder)protected voidcreateIndex(IDBIndex index, java.sql.Statement statement, int num)protected voidcreateIndexFields(IDBIndex index, java.lang.StringBuilder builder)javax.sql.DataSourcecreateJDBCDataSource()Deprecated.As of 4.2 no longer supported because of IP issues for external build dependencies (the vendor driver libs).protected voidcreatePrimaryKey(IDBIndex index, java.lang.StringBuilder builder)protected voidcreateTable(java.sql.Connection connection, IDBTable table, IDBTableDelta delta)booleancreateTable(IDBTable table, java.sql.Statement statement)java.util.Set<IDBTable>createTables(java.lang.Iterable<? extends IDBTable> tables, java.sql.Connection connection)protected voiddoCreateTable(IDBTable table, java.sql.Statement statement)protected voiddropField(java.sql.Connection connection, java.lang.String tableName, java.lang.String fieldName)protected voiddropIndex(java.sql.Connection connection, IDBIndex index, IDBIndexDelta delta)protected voiddropIndex(IDBIndex index, java.lang.StringBuilder builder)protected voiddropPrimaryKey(IDBIndex index, java.lang.StringBuilder builder)protected voiddropTable(java.sql.Connection connection, IDBTable table, IDBTableDelta delta)booleandropTable(IDBTable table, java.sql.Statement statement)java.util.Collection<IDBTable>dropTables(java.lang.Iterable<? extends IDBTable> tables, java.sql.Connection connection)java.lang.Stringformat(java.sql.PreparedStatement stmt)java.lang.Stringformat(java.sql.ResultSet resultSet)protected static voidgenerateReservedWords(java.sql.Connection connection, java.lang.String[] words)static intgetDefaultDBLength(DBType type)protected java.lang.StringgetDropTableSQL(IDBTable table)intgetFieldLength(DBType type)Returns the column length for the given database type.java.sql.DrivergetJDBCDriver()Deprecated.As of 4.2 no longer supported because of IP issues for external build dependencies (the vendor driver libs).intgetMaxFieldNameLength()intgetMaxTableNameLength()java.lang.StringgetName()java.lang.String[]getSQL92ReservedWords()protected java.lang.StringgetTypeName(IDBField field)java.lang.StringgetVersion()booleanisColumnNotFoundException(java.sql.SQLException ex)booleanisDuplicateKeyException(java.sql.SQLException ex)Check if an exception indicates a constraint violation (duplicate key)protected booleanisPrimaryKeyShadow(java.sql.Connection connection, IDBTable table, java.lang.String name, IDBIndex.Type type, IDBField[] fields)booleanisReservedWord(java.lang.String word)booleanisTableNotFoundException(java.sql.SQLException ex)booleanisTypeIndexable(DBType type)booleanisValidFirstChar(char ch)Check if a character is valid as first character.java.sql.ConnectionmodifyConnection(java.sql.Connection connection)IDBSchemaTransactionopenSchemaTransaction(IDBDatabase database, IDBConnection currentConnection)protected voidreadFields(java.sql.Connection connection, IDBTable table)protected voidreadIndices(java.sql.Connection connection, java.sql.DatabaseMetaData metaData, IDBTable table, java.lang.String schemaName)protected voidreadIndices(java.sql.Connection connection, java.sql.ResultSet resultSet, IDBTable table, int indexNameColumn, int indexTypeColumn, int fieldNameColumn, int fieldPositionColumn)IDBSchemareadSchema(java.sql.Connection connection, java.lang.String name)voidreadSchema(java.sql.Connection connection, IDBSchema schema)protected java.sql.ResultSetreadTables(java.sql.Connection connection, java.sql.DatabaseMetaData metaData, java.lang.String schemaName)protected java.lang.StringsqlModifyField(java.lang.String tableName, java.lang.String fieldName, java.lang.String definition)java.lang.StringsqlModifyField(IDBField field)java.lang.StringsqlRenameField(IDBField field, java.lang.String oldName)java.lang.StringtoString()voidupdateSchema(java.sql.Connection connection, IDBSchema schema, IDBSchemaDelta delta)protected voidvalidateTable(IDBTable table, java.sql.Statement statement)- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface org.eclipse.net4j.db.IDBAdaptergetReservedWords
 
- 
 
- 
- 
- 
Method Detail- 
getNamepublic java.lang.String getName() - Specified by:
- getNamein interface- IDBAdapter
 
 - 
getVersionpublic java.lang.String getVersion() - Specified by:
- getVersionin interface- IDBAdapter
 
 - 
getJDBCDriver@Deprecated public java.sql.Driver getJDBCDriver() Deprecated.As of 4.2 no longer supported because of IP issues for external build dependencies (the vendor driver libs).- Specified by:
- getJDBCDriverin interface- IDBAdapter
- Since:
- 4.2
 
 - 
createJDBCDataSource@Deprecated public javax.sql.DataSource createJDBCDataSource() Deprecated.As of 4.2 no longer supported because of IP issues for external build dependencies (the vendor driver libs).- Specified by:
- createJDBCDataSourcein interface- IDBAdapter
- Since:
- 4.2
 
 - 
createConnectionProviderpublic IDBConnectionProvider createConnectionProvider(javax.sql.DataSource dataSource) - Specified by:
- createConnectionProviderin interface- IDBAdapter
- Since:
- 4.3
 
 - 
modifyConnectionpublic java.sql.Connection modifyConnection(java.sql.Connection connection) - Specified by:
- modifyConnectionin interface- IDBAdapter
- Since:
- 4.5
 
 - 
openSchemaTransactionpublic IDBSchemaTransaction openSchemaTransaction(IDBDatabase database, IDBConnection currentConnection) - Since:
- 4.9
 
 - 
readSchemapublic IDBSchema readSchema(java.sql.Connection connection, java.lang.String name) - Specified by:
- readSchemain interface- IDBAdapter
- Since:
- 4.2
 
 - 
readSchemapublic void readSchema(java.sql.Connection connection, IDBSchema schema)- Specified by:
- readSchemain interface- IDBAdapter
- Since:
- 4.2
 
 - 
readTablesprotected java.sql.ResultSet readTables(java.sql.Connection connection, java.sql.DatabaseMetaData metaData, java.lang.String schemaName) throws java.sql.SQLException- Throws:
- java.sql.SQLException
- Since:
- 4.3
 
 - 
readFieldsprotected void readFields(java.sql.Connection connection, IDBTable table) throws java.sql.SQLException- Throws:
- java.sql.SQLException
- Since:
- 4.2
 
 - 
readIndicesprotected void readIndices(java.sql.Connection connection, java.sql.DatabaseMetaData metaData, IDBTable table, java.lang.String schemaName) throws java.sql.SQLException- Throws:
- java.sql.SQLException
- Since:
- 4.2
 
 - 
readIndicesprotected void readIndices(java.sql.Connection connection, java.sql.ResultSet resultSet, IDBTable table, int indexNameColumn, int indexTypeColumn, int fieldNameColumn, int fieldPositionColumn) throws java.sql.SQLException- Throws:
- java.sql.SQLException
- Since:
- 4.2
 
 - 
addIndexprotected void addIndex(java.sql.Connection connection, IDBTable table, java.lang.String name, IDBIndex.Type type, java.util.List<DBAdapter.FieldInfo> fieldInfos)- Since:
- 4.2
 
 - 
isPrimaryKeyShadowprotected boolean isPrimaryKeyShadow(java.sql.Connection connection, IDBTable table, java.lang.String name, IDBIndex.Type type, IDBField[] fields)- Since:
- 4.2
 
 - 
updateSchemapublic void updateSchema(java.sql.Connection connection, IDBSchema schema, IDBSchemaDelta delta) throws DBException- Specified by:
- updateSchemain interface- IDBAdapter
- Throws:
- DBException
- Since:
- 4.2
 
 - 
createTableprotected void createTable(java.sql.Connection connection, IDBTable table, IDBTableDelta delta)- Since:
- 4.2
 
 - 
dropTableprotected void dropTable(java.sql.Connection connection, IDBTable table, IDBTableDelta delta)- Since:
- 4.2
 
 - 
alterTableprotected void alterTable(java.sql.Connection connection, IDBTable table, IDBTableDelta delta)- Since:
- 4.2
 
 - 
createFieldprotected void createField(java.sql.Connection connection, java.lang.String tableName, IDBField field)- Since:
- 4.6
 
 - 
dropFieldprotected void dropField(java.sql.Connection connection, java.lang.String tableName, java.lang.String fieldName)- Since:
- 4.6
 
 - 
createIndexprotected void createIndex(java.sql.Connection connection, IDBIndex index, IDBIndexDelta delta)- Since:
- 4.2
 
 - 
createPrimaryKeyprotected void createPrimaryKey(IDBIndex index, java.lang.StringBuilder builder) - Since:
- 4.2
 
 - 
createIndexprotected void createIndex(IDBIndex index, java.lang.StringBuilder builder) - Since:
- 4.2
 
 - 
createIndexFieldsprotected void createIndexFields(IDBIndex index, java.lang.StringBuilder builder) - Since:
- 4.2
 
 - 
dropIndexprotected void dropIndex(java.sql.Connection connection, IDBIndex index, IDBIndexDelta delta)- Since:
- 4.2
 
 - 
dropPrimaryKeyprotected void dropPrimaryKey(IDBIndex index, java.lang.StringBuilder builder) - Since:
- 4.2
 
 - 
dropIndexprotected void dropIndex(IDBIndex index, java.lang.StringBuilder builder) - Since:
- 4.2
 
 - 
createTablespublic java.util.Set<IDBTable> createTables(java.lang.Iterable<? extends IDBTable> tables, java.sql.Connection connection) throws DBException - Specified by:
- createTablesin interface- IDBAdapter
- Throws:
- DBException
 
 - 
createTablepublic boolean createTable(IDBTable table, java.sql.Statement statement) throws DBException - Specified by:
- createTablein interface- IDBAdapter
- Throws:
- DBException
 
 - 
dropTablespublic java.util.Collection<IDBTable> dropTables(java.lang.Iterable<? extends IDBTable> tables, java.sql.Connection connection) throws DBException - Specified by:
- dropTablesin interface- IDBAdapter
- Throws:
- DBException
 
 - 
dropTablepublic boolean dropTable(IDBTable table, java.sql.Statement statement) - Specified by:
- dropTablein interface- IDBAdapter
 
 - 
getDropTableSQLprotected java.lang.String getDropTableSQL(IDBTable table) 
 - 
getMaxTableNameLengthpublic int getMaxTableNameLength() - Specified by:
- getMaxTableNameLengthin interface- IDBAdapter
- Since:
- 2.0
 
 - 
getMaxFieldNameLengthpublic int getMaxFieldNameLength() - Specified by:
- getMaxFieldNameLengthin interface- IDBAdapter
- Since:
- 2.0
 
 - 
getFieldLengthpublic int getFieldLength(DBType type) Description copied from interface:IDBAdapterReturns the column length for the given database type.- Specified by:
- getFieldLengthin interface- IDBAdapter
- Parameters:
- type- the- DBTypeto check.
- Returns:
- the supported column length for the type.
- Since:
- 4.2
 
 - 
isTypeIndexablepublic boolean isTypeIndexable(DBType type) - Specified by:
- isTypeIndexablein interface- IDBAdapter
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
convertStringpublic java.lang.String convertString(java.sql.PreparedStatement preparedStatement, int parameterIndex, java.lang.String value)- Since:
- 4.3
 
 - 
convertStringpublic java.lang.String convertString(java.sql.ResultSet resultSet, int columnIndex, java.lang.String value)- Since:
- 4.3
 
 - 
convertStringpublic java.lang.String convertString(java.sql.ResultSet resultSet, java.lang.String columnLabel, java.lang.String value)- Since:
- 4.3
 
 - 
doCreateTableprotected void doCreateTable(IDBTable table, java.sql.Statement statement) throws java.sql.SQLException - Throws:
- java.sql.SQLException
- Since:
- 2.0
 
 - 
createIndexprotected void createIndex(IDBIndex index, java.sql.Statement statement, int num) throws java.sql.SQLException - Throws:
- java.sql.SQLException
- Since:
- 2.0
 
 - 
addIndexFieldprotected void addIndexField(java.lang.StringBuilder builder, IDBField field)
 - 
createConstraintsprotected java.lang.String createConstraints(IDBTable table) - Since:
- 2.0
 
 - 
createFieldDefinitionprotected java.lang.String createFieldDefinition(IDBField field) - Since:
- 2.0
 
 - 
getTypeNameprotected java.lang.String getTypeName(IDBField field) 
 - 
getSQL92ReservedWordspublic java.lang.String[] getSQL92ReservedWords() 
 - 
isReservedWordpublic boolean isReservedWord(java.lang.String word) - Specified by:
- isReservedWordin interface- IDBAdapter
 
 - 
validateTableprotected void validateTable(IDBTable table, java.sql.Statement statement) throws DBException - Throws:
- DBException
- Since:
- 2.0
 
 - 
createFieldDefinitionsprotected java.lang.String[] createFieldDefinitions(IDBTable table) - Since:
- 4.2
 
 - 
appendFieldNamespublic void appendFieldNames(java.lang.Appendable appendable, IDBTable table)
 - 
appendFieldDefsprotected void appendFieldDefs(java.lang.Appendable appendable, IDBTable table, java.lang.String[] defs)- Since:
- 4.2
 
 - 
adaptTypepublic DBType adaptType(DBType type) 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 interface- IDBAdapter
- Since:
- 3.0
 
 - 
isValidFirstCharpublic 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 interface- IDBAdapter
- Since:
- 4.0
 
 - 
isDuplicateKeyExceptionpublic boolean isDuplicateKeyException(java.sql.SQLException ex) Description copied from interface:IDBAdapterCheck if an exception indicates a constraint violation (duplicate key)- Specified by:
- isDuplicateKeyExceptionin interface- IDBAdapter
- Since:
- 4.0
 
 - 
isTableNotFoundExceptionpublic boolean isTableNotFoundException(java.sql.SQLException ex) - Specified by:
- isTableNotFoundExceptionin interface- IDBAdapter
- Since:
- 4.2
 
 - 
isColumnNotFoundExceptionpublic boolean isColumnNotFoundException(java.sql.SQLException ex) - Specified by:
- isColumnNotFoundExceptionin interface- IDBAdapter
- Since:
- 4.2
 
 - 
sqlRenameFieldpublic java.lang.String sqlRenameField(IDBField field, java.lang.String oldName) - Specified by:
- sqlRenameFieldin interface- IDBAdapter
- Since:
- 4.2
 
 - 
sqlModifyFieldpublic java.lang.String sqlModifyField(IDBField field) - Specified by:
- sqlModifyFieldin interface- IDBAdapter
- Since:
- 4.2
 
 - 
sqlModifyFieldprotected java.lang.String sqlModifyField(java.lang.String tableName, java.lang.String fieldName, java.lang.String definition)- Since:
- 4.2
 
 - 
formatpublic java.lang.String format(java.sql.PreparedStatement stmt) - Since:
- 4.2
 
 - 
formatpublic java.lang.String format(java.sql.ResultSet resultSet) - Since:
- 4.2
 
 - 
convertToSQLpublic java.lang.Object convertToSQL(java.lang.Object value) - Since:
- 4.9
 
 - 
getDefaultDBLengthpublic static int getDefaultDBLength(DBType type) - Since:
- 4.2
 
 - 
generateReservedWordsprotected static void generateReservedWords(java.sql.Connection connection, java.lang.String[] words) throws java.sql.SQLException- Throws:
- java.sql.SQLException
- Since:
- 4.9
 
 
- 
 
-