com.im.commons.db 5.9.2

com.im.commons.db.ddl
Class AbstractDBInfo

java.lang.Object
  extended by com.im.commons.db.ddl.AbstractDBInfo
All Implemented Interfaces:
DBDatabaseInfo, Serializable

public abstract class AbstractDBInfo
extends Object
implements DBDatabaseInfo

See Also:
Serialized Form

Nested Class Summary
 class AbstractDBInfo.AbstractDateValueColumnConvertor
           
 class AbstractDBInfo.BooleanColumnValueConvertorFactory
           
 class AbstractDBInfo.BooleanValueColumnConvertor
           
static interface AbstractDBInfo.ColumnValueConvertor
           
static interface AbstractDBInfo.ColumnValueConvertorFactory
           
 class AbstractDBInfo.DateColumnValueConvertorFactory
           
 class AbstractDBInfo.LongDateValueColumnConvertor
           
static class AbstractDBInfo.PlatformNativeType
           
 class AbstractDBInfo.SQLDateValueColumnConvertor
           
 
Nested classes/interfaces inherited from interface com.im.commons.db.ddl.DBDatabaseInfo
DBDatabaseInfo.ColumnSizing, DBDatabaseInfo.ColumnSQLType, DBDatabaseInfo.DatabaseOperation, DBDatabaseInfo.NativeType, DBDatabaseInfo.PKType, DBDatabaseInfo.ResizingSupported
 
Field Summary
protected  String cartEnvironment
           
static Map<Integer,String> TYPES_MAP
           
protected  Set<DBDatabaseInfo.DatabaseOperation> unsupportedDatabaseOperations
           
 
Fields inherited from interface com.im.commons.db.ddl.DBDatabaseInfo
ARRAY, BIGINT, BINARY, BIT, BLOB, BOOLEAN, CART_PROP_JChemPropertiesTable, CART_PROP_TableType, CHAR, CLOB, DATALINK, DATE, DECIMAL, DEFAULT_JCHEMPROPERTIES_TABLE_NAME, DISTINCT, DOUBLE, FLOAT, INDEX_UNIQUE, INT, INTEGER, JAVA_OBJECT, LONGVARBINARY, LONGVARCHAR, NULL, NUMBER, NUMERIC, NVARCHAR, NVARCHAR2, OTHER, REAL, REF, SMALLINT, STRUCT, TIME, TIMESTAMP, TINYINT, VARBINARY, VARCHAR, VARCHAR2
 
Constructor Summary
AbstractDBInfo(Properties sqlTemplates, DBType dbType, String dbIdentifierQuoteString)
           
AbstractDBInfo(Properties sqlTemplates, DBType dbType, String dbIdentifierQuoteString, String cartOwner, String cartEnv)
           
 
Method Summary
protected  void addSQLWriter(DBDatabaseInfo.ColumnSQLType colType, SQLWriter.SQLValueWriter writer)
           
 DBDatabaseInfo.NativeType[] availableNativeTypesForColumnType(String columnType)
          Get the native types that this platform supports for this particular column type.
 String convertAndWriteVariable(String clsName, DBDatabaseInfo.ColumnSQLType columnType, Object var)
          Write this variable as a String so that it can be used in a DDL or DML statement.
 boolean convertNamesToUpperCase()
          Informs whether used DB platform uses upper case for names.
 Object createBindVariable(String clsName, DBDatabaseInfo.ColumnSQLType columnType, Object var)
          create a bind variable that can be used in a PreparedStatment.
 String fixNativeType(String nativeType)
          Convert the native type to its correct form (adjust for Oracle quirks!).
 String getCartridgeOwner()
          Get the user who owns the cartridge functions, or null if the DB does not support the JChem cartridge or the cartridge is not installed.
 String getDBIdentifierQuoteString()
          Get the identifier needed to quote identifiers (e..g column names) for this DB.
 DBType getDBType()
           
 String getDeleteRuleAction(int actionCode)
          Returns a string representation of the action code for delete rule in a FK.
 String getJChemCartServerJChemTableVersion()
          Get the index version number used by the cartridge.
 String getJChemCartServerJChemVersion()
          Get the JChem version number used by the cartridge.
 int getMaxColumnNameLength()
          Retrieves the maximum number of characters this database allows for a column name.
 int getMaxElementsInList()
           
 int getMaxIndexNameLength()
          Retrieves the maximum number of characters this database allows for a index name.
 int getMaxTableNameLength()
          Retrieves the maximum number of characters this database allows in a table name.
 SQLElementFactory getSQLElementFactory()
           
 SQLWriter getSQLWriter()
           
 Set<DBDatabaseInfo.DatabaseOperation> getUnsupportedDatabaseOperations()
           
 String getUpdateRuleAction(int actionCode)
          Returns a string representation of the action code for update rule in a FK.
 Integer isCartridgeJChemTableVersionCurrent()
          Compare the table version used by the cartridge to the one used by JChem.
 Integer isCartridgeJChemVersionCurrent()
          Compare the JChem version to the JChem cartridge to the one used by the JChem version that is being used here.
static String[] lookupArrayValues(Properties props, String key)
           
 DBDatabaseInfo.NativeType nativeType(int jdbcType, String suppliedType)
          Create a native type.
 DBDatabaseInfo.NativeType nativeType(int jdbcType, String suppliedType, int size)
          Create a native type.
 DBDatabaseInfo.NativeType nativeType(int jdbcType, String suppliedType, int size, int scale)
          Create the native type for these settings.
 DBDatabaseInfo.NativeType nativeType(String nativeColumnType)
          Create the NativeType for the specified column type.
protected static void registerJdbcType(int jdbcType, String name)
           
 boolean requiresNotNullDefault()
          Determines if it is legal to declare a column NOT NULL while giving no default value.
 boolean requiresNotNullDefault(DBDatabaseInfo.ColumnSQLType type)
          Determines if it is legal to declare a column NOT NULL while giving no default value.
 boolean requiresNotNullFK()
          Determines, if the columns participating in FK must be NOT NULL.
 boolean requiresNotNullUnique()
          Determines, if the DB requires a NOT NULL constraint before an UQ can be created for the field.
 String[] supportedForeignKeyOnDeleteValues()
           
 String[] supportedForeignKeyOnUpdateValues()
           
 String[] supportedIndexTypes()
           
 boolean supportsOperation(DBDatabaseInfo.DatabaseOperation op)
          Is this operation supported by the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.im.commons.db.ddl.DBDatabaseInfo
isSupportsSchemas, prepareDefaultFromDatabaseMetadata
 

Field Detail

TYPES_MAP

public static final Map<Integer,String> TYPES_MAP

unsupportedDatabaseOperations

protected Set<DBDatabaseInfo.DatabaseOperation> unsupportedDatabaseOperations

cartEnvironment

protected String cartEnvironment
Constructor Detail

AbstractDBInfo

public AbstractDBInfo(Properties sqlTemplates,
                      DBType dbType,
                      String dbIdentifierQuoteString,
                      String cartOwner,
                      String cartEnv)

AbstractDBInfo

public AbstractDBInfo(Properties sqlTemplates,
                      DBType dbType,
                      String dbIdentifierQuoteString)
Method Detail

registerJdbcType

protected static void registerJdbcType(int jdbcType,
                                       String name)

getDBIdentifierQuoteString

public String getDBIdentifierQuoteString()
Description copied from interface: DBDatabaseInfo
Get the identifier needed to quote identifiers (e..g column names) for this DB.

Specified by:
getDBIdentifierQuoteString in interface DBDatabaseInfo

getDBType

public DBType getDBType()
Specified by:
getDBType in interface DBDatabaseInfo

supportsOperation

public boolean supportsOperation(DBDatabaseInfo.DatabaseOperation op)
Is this operation supported by the database. To mark an operation as not supported subclasses should add it to the unsupportedDatabaseOperations Set;

Specified by:
supportsOperation in interface DBDatabaseInfo
Returns:
True.

getUnsupportedDatabaseOperations

public Set<DBDatabaseInfo.DatabaseOperation> getUnsupportedDatabaseOperations()
Specified by:
getUnsupportedDatabaseOperations in interface DBDatabaseInfo

supportedIndexTypes

public String[] supportedIndexTypes()
Specified by:
supportedIndexTypes in interface DBDatabaseInfo

getSQLElementFactory

public SQLElementFactory getSQLElementFactory()
Specified by:
getSQLElementFactory in interface DBDatabaseInfo

getMaxElementsInList

public int getMaxElementsInList()
Specified by:
getMaxElementsInList in interface DBDatabaseInfo

getMaxTableNameLength

public int getMaxTableNameLength()
Description copied from interface: DBDatabaseInfo
Retrieves the maximum number of characters this database allows in a table name.

Specified by:
getMaxTableNameLength in interface DBDatabaseInfo

getMaxColumnNameLength

public int getMaxColumnNameLength()
Description copied from interface: DBDatabaseInfo
Retrieves the maximum number of characters this database allows for a column name.

Specified by:
getMaxColumnNameLength in interface DBDatabaseInfo

getMaxIndexNameLength

public int getMaxIndexNameLength()
Description copied from interface: DBDatabaseInfo
Retrieves the maximum number of characters this database allows for a index name.

Specified by:
getMaxIndexNameLength in interface DBDatabaseInfo

getCartridgeOwner

public String getCartridgeOwner()
Description copied from interface: DBDatabaseInfo
Get the user who owns the cartridge functions, or null if the DB does not support the JChem cartridge or the cartridge is not installed.

Specified by:
getCartridgeOwner in interface DBDatabaseInfo
Returns:
The owner

getJChemCartServerJChemVersion

public String getJChemCartServerJChemVersion()
Get the JChem version number used by the cartridge. e.g. 5.1.1. If the cart is not present then null will be returned.

Specified by:
getJChemCartServerJChemVersion in interface DBDatabaseInfo
Returns:
The JChem version
See Also:
VersionInfoo

getJChemCartServerJChemTableVersion

public String getJChemCartServerJChemTableVersion()
Get the index version number used by the cartridge. This is the same as the JChem table version. e.g. 50102 This is only available since JChem 5.1.2. If prior to this, or the cart is not present then null is returned. Note that this is related to the JChem version but the table version is not increased with every JChem version, so it may lag a version or two behind.

Specified by:
getJChemCartServerJChemTableVersion in interface DBDatabaseInfo
Returns:
The cartridge JChem table version
See Also:
VersionInfoo

isCartridgeJChemVersionCurrent

public Integer isCartridgeJChemVersionCurrent()
Compare the JChem version to the JChem cartridge to the one used by the JChem version that is being used here.

Specified by:
isCartridgeJChemVersionCurrent in interface DBDatabaseInfo
Returns:
0 if the JChem version is the same, a negative number if the cartridge version is older than the one in use, a positive number if it is newer, and null if the cart is not enabled
See Also:
VersionInfoo

isCartridgeJChemTableVersionCurrent

public Integer isCartridgeJChemTableVersionCurrent()
Compare the table version used by the cartridge to the one used by JChem. If the table version is not available (older JChem versions), or cannot be recognised then the JChem versions are compared.

Specified by:
isCartridgeJChemTableVersionCurrent in interface DBDatabaseInfo
Returns:
0 if the table versions are the same, a negative number if the cartridge version is older than the one in use in the local jchem.jar, a positive number if the cartridge version is newer, and null if the cart is not enabled.
See Also:
VersionInfoo

nativeType

public DBDatabaseInfo.NativeType nativeType(String nativeColumnType)
Create the NativeType for the specified column type.

Specified by:
nativeType in interface DBDatabaseInfo
Parameters:
nativeColumnType - The actual column definition in the database e.g. VARCHAR2, FLOAT... The JDBC type, length and scale will be set to zero as they are unspecified.

nativeType

public final DBDatabaseInfo.NativeType nativeType(int jdbcType,
                                                  String suppliedType)
Description copied from interface: DBDatabaseInfo
Create a native type. Length and scale will be set to zero as they are unspecified.

Specified by:
nativeType in interface DBDatabaseInfo
Parameters:
jdbcType - (@link java.sql.Types}
suppliedType - The name of native type name DBDatabaseInfo.ColumnSQLType

nativeType

public final DBDatabaseInfo.NativeType nativeType(int jdbcType,
                                                  String suppliedType,
                                                  int size)
Description copied from interface: DBDatabaseInfo
Create a native type. Scale is not defined.

Specified by:
nativeType in interface DBDatabaseInfo
Parameters:
jdbcType - (@link java.sql.Types}
suppliedType - The name of native type name DBDatabaseInfo.ColumnSQLType
size - The size of the type

nativeType

public DBDatabaseInfo.NativeType nativeType(int jdbcType,
                                            String suppliedType,
                                            int size,
                                            int scale)
Create the native type for these settings. If the suppliedType is not specified then a "best guess" will be used.

Specified by:
nativeType in interface DBDatabaseInfo
Parameters:
jdbcType - (@link java.sql.Types}
suppliedType - The name of native type name DBDatabaseInfo.ColumnSQLType
size - The size of the type
scale - The scale of the type

availableNativeTypesForColumnType

public DBDatabaseInfo.NativeType[] availableNativeTypesForColumnType(String columnType)
Get the native types that this platform supports for this particular column type.

Specified by:
availableNativeTypesForColumnType in interface DBDatabaseInfo
Parameters:
columnType - The generic type of the column (TEXT, INTEGER) defined by the constants in DBDatabaseInfo.ColumnBoundTypes
Returns:
An array of compatible column native types

requiresNotNullDefault

public boolean requiresNotNullDefault()
Description copied from interface: DBDatabaseInfo
Determines if it is legal to declare a column NOT NULL while giving no default value. Database platform dependent.

Specified by:
requiresNotNullDefault in interface DBDatabaseInfo
Returns:
True, if the default value is required, false otherwise

requiresNotNullDefault

public boolean requiresNotNullDefault(DBDatabaseInfo.ColumnSQLType type)
Determines if it is legal to declare a column NOT NULL while giving no default value. It is not database platform dependent. It is an application logic.

Specified by:
requiresNotNullDefault in interface DBDatabaseInfo
Parameters:
type -

requiresNotNullFK

public boolean requiresNotNullFK()
Determines, if the columns participating in FK must be NOT NULL.

Specified by:
requiresNotNullFK in interface DBDatabaseInfo
Returns:
True, if the column must be NOT NULL before FK to it can be made

requiresNotNullUnique

public boolean requiresNotNullUnique()
Determines, if the DB requires a NOT NULL constraint before an UQ can be created for the field.

Specified by:
requiresNotNullUnique in interface DBDatabaseInfo
Returns:
True, if a field participating in UNIQUE constraint must be NOT NULL

supportedForeignKeyOnDeleteValues

public String[] supportedForeignKeyOnDeleteValues()
Specified by:
supportedForeignKeyOnDeleteValues in interface DBDatabaseInfo

supportedForeignKeyOnUpdateValues

public String[] supportedForeignKeyOnUpdateValues()
Specified by:
supportedForeignKeyOnUpdateValues in interface DBDatabaseInfo

getUpdateRuleAction

public String getUpdateRuleAction(int actionCode)
Returns a string representation of the action code for update rule in a FK.

Specified by:
getUpdateRuleAction in interface DBDatabaseInfo
Parameters:
actionCode - The action code
Returns:
The string representation of the action code

getDeleteRuleAction

public String getDeleteRuleAction(int actionCode)
Returns a string representation of the action code for delete rule in a FK.

Specified by:
getDeleteRuleAction in interface DBDatabaseInfo
Parameters:
actionCode - The action code
Returns:
The string representation of the action code

fixNativeType

public String fixNativeType(String nativeType)
Convert the native type to its correct form (adjust for Oracle quirks!).

Specified by:
fixNativeType in interface DBDatabaseInfo
Parameters:
nativeType -
Returns:
The corrected native type

lookupArrayValues

public static String[] lookupArrayValues(Properties props,
                                         String key)

convertAndWriteVariable

public String convertAndWriteVariable(String clsName,
                                      DBDatabaseInfo.ColumnSQLType columnType,
                                      Object var)
Write this variable as a String so that it can be used in a DDL or DML statement.

Specified by:
convertAndWriteVariable in interface DBDatabaseInfo

createBindVariable

public Object createBindVariable(String clsName,
                                 DBDatabaseInfo.ColumnSQLType columnType,
                                 Object var)
create a bind variable that can be used in a PreparedStatment.

Specified by:
createBindVariable in interface DBDatabaseInfo

getSQLWriter

public SQLWriter getSQLWriter()
Specified by:
getSQLWriter in interface DBDatabaseInfo

addSQLWriter

protected void addSQLWriter(DBDatabaseInfo.ColumnSQLType colType,
                            SQLWriter.SQLValueWriter writer)

convertNamesToUpperCase

public boolean convertNamesToUpperCase()
Description copied from interface: DBDatabaseInfo
Informs whether used DB platform uses upper case for names.

Specified by:
convertNamesToUpperCase in interface DBDatabaseInfo
Returns:
false only if db platform defines property metadata-convertNamesToUpperCase and that property is set to 'false'. In all other cases returns false.

com.im.commons.db 5.9.2