public abstract class DBAdapter extends Object implements IDBAdapter
DB adapters
.Modifier and Type | Class and Description |
---|---|
protected static class |
DBAdapter.FieldInfo |
REGISTRY
Modifier and Type | Method and Description |
---|---|
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) |
IDBConnectionProvider |
createConnectionProvider(DataSource dataSource) |
protected String |
createConstraints(IDBTable table) |
protected String |
createFieldDefinition(IDBField field) |
protected String[] |
createFieldDefinitions(IDBTable table) |
protected void |
createIndex(Connection connection,
IDBIndex index,
IDBIndexDelta delta) |
protected void |
createIndex(IDBIndex index,
Statement statement,
int num) |
protected void |
createIndex(IDBIndex index,
StringBuilder builder) |
protected void |
createIndexFields(IDBIndex index,
StringBuilder builder) |
DataSource |
createJDBCDataSource()
Deprecated.
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) |
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 |
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) |
static int |
getDefaultDBLength(DBType type) |
protected String |
getDropTableSQL(IDBTable table) |
int |
getFieldLength(DBType type)
Returns the column length for the given database type.
|
Driver |
getJDBCDriver()
Deprecated.
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() |
String[] |
getSQL92ReservedWords() |
protected String |
getTypeName(IDBField field) |
String |
getVersion() |
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.
|
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) |
void |
readSchema(Connection connection,
IDBSchema schema) |
IDBSchema |
readSchema(Connection connection,
String name) |
protected ResultSet |
readTables(Connection connection,
DatabaseMetaData metaData,
String schemaName) |
String |
sqlModifyField(IDBField field) |
protected String |
sqlModifyField(String tableName,
String fieldName,
String definition) |
String |
sqlRenameField(IDBField field,
String oldName) |
String |
toString() |
void |
updateSchema(Connection connection,
IDBSchema schema,
IDBSchemaDelta delta) |
protected void |
validateTable(IDBTable table,
Statement statement) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getReservedWords
public String getName()
getName
in interface IDBAdapter
public String getVersion()
getVersion
in interface IDBAdapter
@Deprecated public Driver getJDBCDriver()
getJDBCDriver
in interface IDBAdapter
@Deprecated public DataSource createJDBCDataSource()
createJDBCDataSource
in interface IDBAdapter
public IDBConnectionProvider createConnectionProvider(DataSource dataSource)
createConnectionProvider
in interface IDBAdapter
public IDBSchema readSchema(Connection connection, String name)
readSchema
in interface IDBAdapter
public void readSchema(Connection connection, IDBSchema schema)
readSchema
in interface IDBAdapter
protected ResultSet readTables(Connection connection, DatabaseMetaData metaData, String schemaName) throws SQLException
SQLException
protected void readFields(Connection connection, IDBTable table) throws SQLException
SQLException
protected void readIndices(Connection connection, DatabaseMetaData metaData, IDBTable table, String schemaName) throws SQLException
SQLException
protected void readIndices(Connection connection, ResultSet resultSet, IDBTable table, int indexNameColumn, int indexTypeColumn, int fieldNameColumn, int fieldPositionColumn) throws SQLException
SQLException
protected void addIndex(Connection connection, IDBTable table, String name, IDBIndex.Type type, List<DBAdapter.FieldInfo> fieldInfos)
protected boolean isPrimaryKeyShadow(Connection connection, IDBTable table, String name, IDBIndex.Type type, IDBField[] fields)
public void updateSchema(Connection connection, IDBSchema schema, IDBSchemaDelta delta) throws DBException
updateSchema
in interface IDBAdapter
DBException
protected void createTable(Connection connection, IDBTable table, IDBTableDelta delta)
protected void dropTable(Connection connection, IDBTable table, IDBTableDelta delta)
protected void alterTable(Connection connection, IDBTable table, IDBTableDelta delta)
protected void createIndex(Connection connection, IDBIndex index, IDBIndexDelta delta)
protected void createPrimaryKey(IDBIndex index, StringBuilder builder)
protected void createIndex(IDBIndex index, StringBuilder builder)
protected void createIndexFields(IDBIndex index, StringBuilder builder)
protected void dropIndex(Connection connection, IDBIndex index, IDBIndexDelta delta)
protected void dropPrimaryKey(IDBIndex index, StringBuilder builder)
protected void dropIndex(IDBIndex index, StringBuilder builder)
public Set<IDBTable> createTables(Iterable<? extends IDBTable> tables, Connection connection) throws DBException
createTables
in interface IDBAdapter
DBException
public boolean createTable(IDBTable table, Statement statement) throws DBException
createTable
in interface IDBAdapter
DBException
public Collection<IDBTable> dropTables(Iterable<? extends IDBTable> tables, Connection connection) throws DBException
dropTables
in interface IDBAdapter
DBException
public boolean dropTable(IDBTable table, Statement statement)
dropTable
in interface IDBAdapter
public int getMaxTableNameLength()
getMaxTableNameLength
in interface IDBAdapter
public int getMaxFieldNameLength()
getMaxFieldNameLength
in interface IDBAdapter
public int getFieldLength(DBType type)
IDBAdapter
getFieldLength
in interface IDBAdapter
type
- the DBType
to check.public boolean isTypeIndexable(DBType type)
isTypeIndexable
in interface IDBAdapter
public String convertString(PreparedStatement preparedStatement, int parameterIndex, String value)
public String convertString(ResultSet resultSet, int columnIndex, String value)
public String convertString(ResultSet resultSet, String columnLabel, String value)
protected void doCreateTable(IDBTable table, Statement statement) throws SQLException
SQLException
protected void createIndex(IDBIndex index, Statement statement, int num) throws SQLException
SQLException
protected void addIndexField(StringBuilder builder, IDBField field)
public String[] getSQL92ReservedWords()
public boolean isReservedWord(String word)
isReservedWord
in interface IDBAdapter
protected void validateTable(IDBTable table, Statement statement) throws DBException
DBException
public void appendFieldNames(Appendable appendable, IDBTable table)
protected void appendFieldDefs(Appendable appendable, IDBTable table, String[] defs)
public DBType adaptType(DBType type)
IDBAdapter
adaptType
in interface IDBAdapter
public boolean isValidFirstChar(char ch)
IDBAdapter
isValidFirstChar
in interface IDBAdapter
public boolean isDuplicateKeyException(SQLException ex)
IDBAdapter
isDuplicateKeyException
in interface IDBAdapter
public boolean isTableNotFoundException(SQLException ex)
isTableNotFoundException
in interface IDBAdapter
public boolean isColumnNotFoundException(SQLException ex)
isColumnNotFoundException
in interface IDBAdapter
public String sqlRenameField(IDBField field, String oldName)
sqlRenameField
in interface IDBAdapter
public String sqlModifyField(IDBField field)
sqlModifyField
in interface IDBAdapter
protected String sqlModifyField(String tableName, String fieldName, String definition)
public String format(PreparedStatement stmt)
public static int getDefaultDBLength(DBType type)
Copyright (c) 2011-2014 Eike Stepper (Berlin, Germany) and others.