public abstract class DBAdapter extends java.lang.Object implements IDBAdapter
DB adapters.| Modifier and Type | Class and Description |
|---|---|
protected static class |
DBAdapter.FieldInfo |
REGISTRY| Constructor and Description |
|---|
DBAdapter(java.lang.String name,
java.lang.String version) |
| 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(java.sql.Connection connection,
IDBTable table,
java.lang.String name,
IDBIndex.Type type,
java.util.List<DBAdapter.FieldInfo> fieldInfos) |
protected void |
addIndexField(java.lang.StringBuilder builder,
IDBField field) |
protected void |
alterTable(java.sql.Connection connection,
IDBTable table,
IDBTableDelta delta) |
protected void |
appendFieldDefs(java.lang.Appendable appendable,
IDBTable table,
java.lang.String[] defs) |
void |
appendFieldNames(java.lang.Appendable appendable,
IDBTable table) |
java.lang.String |
convertString(java.sql.PreparedStatement preparedStatement,
int parameterIndex,
java.lang.String value) |
java.lang.String |
convertString(java.sql.ResultSet resultSet,
int columnIndex,
java.lang.String value) |
java.lang.String |
convertString(java.sql.ResultSet resultSet,
java.lang.String columnLabel,
java.lang.String value) |
IDBConnectionProvider |
createConnectionProvider(javax.sql.DataSource dataSource) |
protected java.lang.String |
createConstraints(IDBTable table) |
protected void |
createField(java.sql.Connection connection,
java.lang.String tableName,
IDBField field) |
protected java.lang.String |
createFieldDefinition(IDBField field) |
protected java.lang.String[] |
createFieldDefinitions(IDBTable table) |
protected void |
createIndex(java.sql.Connection connection,
IDBIndex index,
IDBIndexDelta delta) |
protected void |
createIndex(IDBIndex index,
java.sql.Statement statement,
int num) |
protected void |
createIndex(IDBIndex index,
java.lang.StringBuilder builder) |
protected void |
createIndexFields(IDBIndex index,
java.lang.StringBuilder builder) |
javax.sql.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,
java.lang.StringBuilder builder) |
protected void |
createTable(java.sql.Connection connection,
IDBTable table,
IDBTableDelta delta) |
boolean |
createTable(IDBTable table,
java.sql.Statement statement) |
java.util.Set<IDBTable> |
createTables(java.lang.Iterable<? extends IDBTable> tables,
java.sql.Connection connection) |
protected void |
doCreateTable(IDBTable table,
java.sql.Statement statement) |
protected void |
dropField(java.sql.Connection connection,
java.lang.String tableName,
java.lang.String fieldName) |
protected void |
dropIndex(java.sql.Connection connection,
IDBIndex index,
IDBIndexDelta delta) |
protected void |
dropIndex(IDBIndex index,
java.lang.StringBuilder builder) |
protected void |
dropPrimaryKey(IDBIndex index,
java.lang.StringBuilder builder) |
protected void |
dropTable(java.sql.Connection connection,
IDBTable table,
IDBTableDelta delta) |
boolean |
dropTable(IDBTable table,
java.sql.Statement statement) |
java.util.Collection<IDBTable> |
dropTables(java.lang.Iterable<? extends IDBTable> tables,
java.sql.Connection connection) |
java.lang.String |
format(java.sql.PreparedStatement stmt) |
java.lang.String |
format(java.sql.ResultSet resultSet) |
static int |
getDefaultDBLength(DBType type) |
protected java.lang.String |
getDropTableSQL(IDBTable table) |
int |
getFieldLength(DBType type)
Returns the column length for the given database type.
|
java.sql.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() |
java.lang.String |
getName() |
java.lang.String[] |
getSQL92ReservedWords() |
protected java.lang.String |
getTypeName(IDBField field) |
java.lang.String |
getVersion() |
boolean |
isColumnNotFoundException(java.sql.SQLException ex) |
boolean |
isDuplicateKeyException(java.sql.SQLException ex)
Check if an exception indicates a constraint violation (duplicate key)
|
protected boolean |
isPrimaryKeyShadow(java.sql.Connection connection,
IDBTable table,
java.lang.String name,
IDBIndex.Type type,
IDBField[] fields) |
boolean |
isReservedWord(java.lang.String word) |
boolean |
isTableNotFoundException(java.sql.SQLException ex) |
boolean |
isTypeIndexable(DBType type) |
boolean |
isValidFirstChar(char ch)
Check if a character is valid as first character.
|
java.sql.Connection |
modifyConnection(java.sql.Connection connection) |
protected void |
readFields(java.sql.Connection connection,
IDBTable table) |
protected void |
readIndices(java.sql.Connection connection,
java.sql.DatabaseMetaData metaData,
IDBTable table,
java.lang.String schemaName) |
protected void |
readIndices(java.sql.Connection connection,
java.sql.ResultSet resultSet,
IDBTable table,
int indexNameColumn,
int indexTypeColumn,
int fieldNameColumn,
int fieldPositionColumn) |
void |
readSchema(java.sql.Connection connection,
IDBSchema schema) |
IDBSchema |
readSchema(java.sql.Connection connection,
java.lang.String name) |
protected java.sql.ResultSet |
readTables(java.sql.Connection connection,
java.sql.DatabaseMetaData metaData,
java.lang.String schemaName) |
java.lang.String |
sqlModifyField(IDBField field) |
protected java.lang.String |
sqlModifyField(java.lang.String tableName,
java.lang.String fieldName,
java.lang.String definition) |
java.lang.String |
sqlRenameField(IDBField field,
java.lang.String oldName) |
java.lang.String |
toString() |
void |
updateSchema(java.sql.Connection connection,
IDBSchema schema,
IDBSchemaDelta delta) |
protected void |
validateTable(IDBTable table,
java.sql.Statement statement) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetReservedWordspublic java.lang.String getName()
getName in interface IDBAdapterpublic java.lang.String getVersion()
getVersion in interface IDBAdapter@Deprecated public java.sql.Driver getJDBCDriver()
getJDBCDriver in interface IDBAdapter@Deprecated public javax.sql.DataSource createJDBCDataSource()
createJDBCDataSource in interface IDBAdapterpublic IDBConnectionProvider createConnectionProvider(javax.sql.DataSource dataSource)
createConnectionProvider in interface IDBAdapterpublic java.sql.Connection modifyConnection(java.sql.Connection connection)
modifyConnection in interface IDBAdapterpublic IDBSchema readSchema(java.sql.Connection connection, java.lang.String name)
readSchema in interface IDBAdapterpublic void readSchema(java.sql.Connection connection,
IDBSchema schema)
readSchema in interface IDBAdapterprotected java.sql.ResultSet readTables(java.sql.Connection connection,
java.sql.DatabaseMetaData metaData,
java.lang.String schemaName)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void readFields(java.sql.Connection connection,
IDBTable table)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void readIndices(java.sql.Connection connection,
java.sql.DatabaseMetaData metaData,
IDBTable table,
java.lang.String schemaName)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void readIndices(java.sql.Connection connection,
java.sql.ResultSet resultSet,
IDBTable table,
int indexNameColumn,
int indexTypeColumn,
int fieldNameColumn,
int fieldPositionColumn)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void addIndex(java.sql.Connection connection,
IDBTable table,
java.lang.String name,
IDBIndex.Type type,
java.util.List<DBAdapter.FieldInfo> fieldInfos)
protected boolean isPrimaryKeyShadow(java.sql.Connection connection,
IDBTable table,
java.lang.String name,
IDBIndex.Type type,
IDBField[] fields)
public void updateSchema(java.sql.Connection connection,
IDBSchema schema,
IDBSchemaDelta delta)
throws DBException
updateSchema in interface IDBAdapterDBExceptionprotected void createTable(java.sql.Connection connection,
IDBTable table,
IDBTableDelta delta)
protected void dropTable(java.sql.Connection connection,
IDBTable table,
IDBTableDelta delta)
protected void alterTable(java.sql.Connection connection,
IDBTable table,
IDBTableDelta delta)
protected void createField(java.sql.Connection connection,
java.lang.String tableName,
IDBField field)
protected void dropField(java.sql.Connection connection,
java.lang.String tableName,
java.lang.String fieldName)
protected void createIndex(java.sql.Connection connection,
IDBIndex index,
IDBIndexDelta delta)
protected void createPrimaryKey(IDBIndex index, java.lang.StringBuilder builder)
protected void createIndex(IDBIndex index, java.lang.StringBuilder builder)
protected void createIndexFields(IDBIndex index, java.lang.StringBuilder builder)
protected void dropIndex(java.sql.Connection connection,
IDBIndex index,
IDBIndexDelta delta)
protected void dropPrimaryKey(IDBIndex index, java.lang.StringBuilder builder)
protected void dropIndex(IDBIndex index, java.lang.StringBuilder builder)
public java.util.Set<IDBTable> createTables(java.lang.Iterable<? extends IDBTable> tables, java.sql.Connection connection) throws DBException
createTables in interface IDBAdapterDBExceptionpublic boolean createTable(IDBTable table, java.sql.Statement statement) throws DBException
createTable in interface IDBAdapterDBExceptionpublic java.util.Collection<IDBTable> dropTables(java.lang.Iterable<? extends IDBTable> tables, java.sql.Connection connection) throws DBException
dropTables in interface IDBAdapterDBExceptionpublic boolean dropTable(IDBTable table, java.sql.Statement statement)
dropTable in interface IDBAdapterprotected java.lang.String getDropTableSQL(IDBTable table)
public int getMaxTableNameLength()
getMaxTableNameLength in interface IDBAdapterpublic int getMaxFieldNameLength()
getMaxFieldNameLength in interface IDBAdapterpublic int getFieldLength(DBType type)
IDBAdaptergetFieldLength in interface IDBAdaptertype - the DBType to check.public boolean isTypeIndexable(DBType type)
isTypeIndexable in interface IDBAdapterpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String convertString(java.sql.PreparedStatement preparedStatement,
int parameterIndex,
java.lang.String value)
public java.lang.String convertString(java.sql.ResultSet resultSet,
int columnIndex,
java.lang.String value)
public java.lang.String convertString(java.sql.ResultSet resultSet,
java.lang.String columnLabel,
java.lang.String value)
protected void doCreateTable(IDBTable table, java.sql.Statement statement) throws java.sql.SQLException
java.sql.SQLExceptionprotected void createIndex(IDBIndex index, java.sql.Statement statement, int num) throws java.sql.SQLException
java.sql.SQLExceptionprotected void addIndexField(java.lang.StringBuilder builder,
IDBField field)
protected java.lang.String createConstraints(IDBTable table)
protected java.lang.String createFieldDefinition(IDBField field)
protected java.lang.String getTypeName(IDBField field)
public java.lang.String[] getSQL92ReservedWords()
public boolean isReservedWord(java.lang.String word)
isReservedWord in interface IDBAdapterprotected void validateTable(IDBTable table, java.sql.Statement statement) throws DBException
DBExceptionprotected java.lang.String[] createFieldDefinitions(IDBTable table)
public void appendFieldNames(java.lang.Appendable appendable,
IDBTable table)
protected void appendFieldDefs(java.lang.Appendable appendable,
IDBTable table,
java.lang.String[] defs)
public DBType adaptType(DBType type)
IDBAdapteradaptType in interface IDBAdapterpublic boolean isValidFirstChar(char ch)
IDBAdapterisValidFirstChar in interface IDBAdapterpublic boolean isDuplicateKeyException(java.sql.SQLException ex)
IDBAdapterisDuplicateKeyException in interface IDBAdapterpublic boolean isTableNotFoundException(java.sql.SQLException ex)
isTableNotFoundException in interface IDBAdapterpublic boolean isColumnNotFoundException(java.sql.SQLException ex)
isColumnNotFoundException in interface IDBAdapterpublic java.lang.String sqlRenameField(IDBField field, java.lang.String oldName)
sqlRenameField in interface IDBAdapterpublic java.lang.String sqlModifyField(IDBField field)
sqlModifyField in interface IDBAdapterprotected java.lang.String sqlModifyField(java.lang.String tableName,
java.lang.String fieldName,
java.lang.String definition)
public java.lang.String format(java.sql.PreparedStatement stmt)
public java.lang.String format(java.sql.ResultSet resultSet)
public static int getDefaultDBLength(DBType type)
Copyright (c) 2004-2019 Eike Stepper (Loehne, Germany) and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html