Package com.im.commons.db.ddl
Interface DBDatabaseInfo
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
AbstractDBInfo
public interface DBDatabaseInfo extends java.io.Serializable
Provides static information about the database. This information does not need to consult the database each time for the answers and can be determined purely from static information and information that can be read from the database on startup and will never change during the lifetime of this instance. The main purpose of instances of this class is to allow client classes to get the information it requires without round trips to the database. Each database type (Oracle, MySQL...) will most likely create a different subclass.TODO P2 - methods related to column sizing are subject to change in the future. This functionality is split between the ColumnSizing and the ResizingSupported enums due to the ResizingSupported enum originally being in
DBDatabaseInfo.ResizingSupported
These 2 enums should somehow be merged. .- Author:
- Tim Dudgeon
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
DBDatabaseInfo.ColumnSizing
Definition of sizing characteristics of column length or scale.static class
DBDatabaseInfo.ColumnSQLType
Column native types.static class
DBDatabaseInfo.DatabaseOperation
Types of database operations.static interface
DBDatabaseInfo.NativeType
Represents a database column native type.static class
DBDatabaseInfo.PKType
Supported primary key typesstatic class
DBDatabaseInfo.ResizingSupported
Enumeration of values for whether a database column can be resized.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ARRAY
static java.lang.String
BIGINT
static java.lang.String
BINARY
static java.lang.String
BIT
static java.lang.String
BLOB
static java.lang.String
BOOLEAN
static java.lang.String
CART_PROP_JChemPropertiesTable
static java.lang.String
CART_PROP_TableType
static java.lang.String
CHAR
static java.lang.String
CLOB
static java.lang.String
DATALINK
static java.lang.String
DATE
static java.lang.String
DECIMAL
static java.lang.String
DEFAULT_JCHEMPROPERTIES_TABLE_NAME
static java.lang.String
DISTINCT
static java.lang.String
DOUBLE
static java.lang.String
FLOAT
static java.lang.String
INDEX_UNIQUE
Constant type for the unique index.static java.lang.String
INT
static java.lang.String
INTEGER
static java.lang.String
JAVA_OBJECT
static java.lang.String
LONGVARBINARY
static java.lang.String
LONGVARCHAR
static java.lang.String
NCHAR
static java.lang.String
NULL
static java.lang.String
NUMBER
static java.lang.String
NUMERIC
static java.lang.String
NVARCHAR
static java.lang.String
NVARCHAR2
static java.lang.String
OTHER
static java.lang.String
REAL
static java.lang.String
REF
static java.lang.String
ROWID
static java.lang.String
SMALLINT
static java.lang.String
STRUCT
static java.lang.String
TIME
static java.lang.String
TIMESTAMP
static java.lang.String
TINYINT
static java.lang.String
VARBINARY
static java.lang.String
VARCHAR
static java.lang.String
VARCHAR2
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DBDatabaseInfo.NativeType[]
availableNativeTypesForColumnType(java.lang.String columnType)
Get the native types that this platform supports for this particular column type.java.lang.String
convertAndWriteVariable(java.lang.String clsName, DBDatabaseInfo.ColumnSQLType columnType, java.lang.Object var)
Write this variable as a String so that it can be used in a DDL or DML statement.boolean
convertNamesToLowerCase()
Informs whether used DB platform uses lower case for names.boolean
convertNamesToUpperCase()
Informs whether used DB platform uses upper case for names.java.lang.Object
createBindVariable(java.lang.String clsName, DBDatabaseInfo.ColumnSQLType columnType, java.lang.Object var)
create a bind variable that can be used in a PreparedStatment.java.lang.String
fixNativeType(java.lang.String nativeType)
Convert the native type to its correct form (adjust for Oracle quirks!).java.lang.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.java.lang.String
getDBIdentifierQuoteString()
Get the identifier needed to quote identifiers (e..g column names) for this DB.DBType
getDBType()
java.lang.String
getDeleteRuleAction(int actionCode)
Returns a string representation of the action code for delete rule in a FK.java.lang.String
getJChemCartServerJChemTableVersion()
Get the index version number used by the cartridge.java.lang.String
getJChemCartServerJChemVersion()
Get the JChem version number used by the cartridge.org.springframework.jdbc.support.lob.LobHandler
getLobHandler()
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.SQLWriter
getSQLWriter()
java.util.Set<DBDatabaseInfo.DatabaseOperation>
getUnsupportedDatabaseOperations()
java.lang.String
getUpdateRuleAction(int actionCode)
Returns a string representation of the action code for update rule in a FK.java.lang.Integer
isCartridgeJChemTableVersionCurrent()
Compare the table version used by the cartridge to the one used by JChem.java.lang.Integer
isCartridgeJChemVersionCurrent()
Compare the JChem version to the JChem cartridge to the one used by the JChem version that is being used here.boolean
isSupportsSchemas()
DBDatabaseInfo.NativeType
nativeType(int jdbcType, java.lang.String nativeType)
Create a native type.DBDatabaseInfo.NativeType
nativeType(int jdbcType, java.lang.String nativeType, int size)
Create a native type.DBDatabaseInfo.NativeType
nativeType(int jdbcType, java.lang.String nativeType, int size, int scale)
Create a native type.DBDatabaseInfo.NativeType
nativeType(java.lang.String type)
Create the NativeType for the specified column type.java.lang.String
prepareDefaultFromDatabaseMetadata(java.lang.String value, DBDatabaseInfo.ColumnSQLType colType)
Convert the default value read from the JDBC metadata data into the real value.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.java.lang.String[]
supportedForeignKeyOnDeleteValues()
java.lang.String[]
supportedForeignKeyOnUpdateValues()
java.lang.String[]
supportedIndexTypes()
boolean
supportsOperation(DBDatabaseInfo.DatabaseOperation op)
Is this operation supported by the database.
-
-
-
Field Detail
-
DEFAULT_JCHEMPROPERTIES_TABLE_NAME
static final java.lang.String DEFAULT_JCHEMPROPERTIES_TABLE_NAME
- See Also:
- Constant Field Values
-
CART_PROP_JChemPropertiesTable
static final java.lang.String CART_PROP_JChemPropertiesTable
- See Also:
- Constant Field Values
-
CART_PROP_TableType
static final java.lang.String CART_PROP_TableType
- See Also:
- Constant Field Values
-
INDEX_UNIQUE
static final java.lang.String INDEX_UNIQUE
Constant type for the unique index.- See Also:
- Constant Field Values
-
ARRAY
static final java.lang.String ARRAY
- See Also:
- Constant Field Values
-
BIGINT
static final java.lang.String BIGINT
- See Also:
- Constant Field Values
-
BINARY
static final java.lang.String BINARY
- See Also:
- Constant Field Values
-
BIT
static final java.lang.String BIT
- See Also:
- Constant Field Values
-
BLOB
static final java.lang.String BLOB
- See Also:
- Constant Field Values
-
BOOLEAN
static final java.lang.String BOOLEAN
- See Also:
- Constant Field Values
-
CHAR
static final java.lang.String CHAR
- See Also:
- Constant Field Values
-
CLOB
static final java.lang.String CLOB
- See Also:
- Constant Field Values
-
DATALINK
static final java.lang.String DATALINK
- See Also:
- Constant Field Values
-
DATE
static final java.lang.String DATE
- See Also:
- Constant Field Values
-
DECIMAL
static final java.lang.String DECIMAL
- See Also:
- Constant Field Values
-
DISTINCT
static final java.lang.String DISTINCT
- See Also:
- Constant Field Values
-
DOUBLE
static final java.lang.String DOUBLE
- See Also:
- Constant Field Values
-
FLOAT
static final java.lang.String FLOAT
- See Also:
- Constant Field Values
-
INT
static final java.lang.String INT
- See Also:
- Constant Field Values
-
INTEGER
static final java.lang.String INTEGER
- See Also:
- Constant Field Values
-
JAVA_OBJECT
static final java.lang.String JAVA_OBJECT
- See Also:
- Constant Field Values
-
LONGVARBINARY
static final java.lang.String LONGVARBINARY
- See Also:
- Constant Field Values
-
LONGVARCHAR
static final java.lang.String LONGVARCHAR
- See Also:
- Constant Field Values
-
NCHAR
static final java.lang.String NCHAR
- See Also:
- Constant Field Values
-
NULL
static final java.lang.String NULL
- See Also:
- Constant Field Values
-
NUMBER
static final java.lang.String NUMBER
- See Also:
- Constant Field Values
-
NUMERIC
static final java.lang.String NUMERIC
- See Also:
- Constant Field Values
-
NVARCHAR
static final java.lang.String NVARCHAR
- See Also:
- Constant Field Values
-
NVARCHAR2
static final java.lang.String NVARCHAR2
- See Also:
- Constant Field Values
-
OTHER
static final java.lang.String OTHER
- See Also:
- Constant Field Values
-
REAL
static final java.lang.String REAL
- See Also:
- Constant Field Values
-
REF
static final java.lang.String REF
- See Also:
- Constant Field Values
-
ROWID
static final java.lang.String ROWID
- See Also:
- Constant Field Values
-
SMALLINT
static final java.lang.String SMALLINT
- See Also:
- Constant Field Values
-
STRUCT
static final java.lang.String STRUCT
- See Also:
- Constant Field Values
-
TIME
static final java.lang.String TIME
- See Also:
- Constant Field Values
-
TIMESTAMP
static final java.lang.String TIMESTAMP
- See Also:
- Constant Field Values
-
TINYINT
static final java.lang.String TINYINT
- See Also:
- Constant Field Values
-
VARBINARY
static final java.lang.String VARBINARY
- See Also:
- Constant Field Values
-
VARCHAR
static final java.lang.String VARCHAR
- See Also:
- Constant Field Values
-
VARCHAR2
static final java.lang.String VARCHAR2
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDBIdentifierQuoteString
java.lang.String getDBIdentifierQuoteString()
Get the identifier needed to quote identifiers (e..g column names) for this DB.
-
getMaxTableNameLength
int getMaxTableNameLength()
Retrieves the maximum number of characters this database allows in a table name.
-
getMaxColumnNameLength
int getMaxColumnNameLength()
Retrieves the maximum number of characters this database allows for a column name.
-
getMaxIndexNameLength
int getMaxIndexNameLength()
Retrieves the maximum number of characters this database allows for a index name.
-
getDBType
DBType getDBType()
-
getUnsupportedDatabaseOperations
java.util.Set<DBDatabaseInfo.DatabaseOperation> getUnsupportedDatabaseOperations()
-
getMaxElementsInList
int getMaxElementsInList()
-
getSQLWriter
SQLWriter getSQLWriter()
-
getLobHandler
org.springframework.jdbc.support.lob.LobHandler getLobHandler()
-
convertAndWriteVariable
java.lang.String convertAndWriteVariable(java.lang.String clsName, DBDatabaseInfo.ColumnSQLType columnType, java.lang.Object var)
Write this variable as a String so that it can be used in a DDL or DML statement.
-
createBindVariable
java.lang.Object createBindVariable(java.lang.String clsName, DBDatabaseInfo.ColumnSQLType columnType, java.lang.Object var)
create a bind variable that can be used in a PreparedStatment.
-
supportsOperation
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;- Returns:
- True.
-
nativeType
DBDatabaseInfo.NativeType nativeType(java.lang.String type)
Create the NativeType for the specified column type. Column type is the native definition for the database e.g. VARCHAR2, FLOAT... The JDBC type, length and scale will be set to zero as they are unspecified.
-
nativeType
DBDatabaseInfo.NativeType nativeType(int jdbcType, java.lang.String nativeType)
Create a native type. Length and scale will be set to zero as they are unspecified.- Parameters:
jdbcType
- (@link java.sql.Types}nativeType
- The name of native type nameDBDatabaseInfo.ColumnSQLType
-
nativeType
DBDatabaseInfo.NativeType nativeType(int jdbcType, java.lang.String nativeType, int size)
Create a native type. Scale is not defined.- Parameters:
jdbcType
- (@link java.sql.Types}nativeType
- The name of native type nameDBDatabaseInfo.ColumnSQLType
size
- The size of the type
-
nativeType
DBDatabaseInfo.NativeType nativeType(int jdbcType, java.lang.String nativeType, int size, int scale)
Create a native type.- Parameters:
jdbcType
- (@link java.sql.Types}nativeType
- The name of native type nameDBDatabaseInfo.ColumnSQLType
size
- The size of the typescale
- The scale of the type
-
availableNativeTypesForColumnType
DBDatabaseInfo.NativeType[] availableNativeTypesForColumnType(java.lang.String columnType)
Get the native types that this platform supports for this particular column type. Type is as defined by the constants in DBDatabaseInfo.ColumnBoundTypes.ColumnTypes
-
requiresNotNullDefault
boolean requiresNotNullDefault()
Determines if it is legal to declare a column NOT NULL while giving no default value. Database platform dependent.- Returns:
- True, if the default value is required, false otherwise
-
requiresNotNullDefault
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.- Parameters:
type
-
-
requiresNotNullFK
boolean requiresNotNullFK()
Determines, if the columns participating in FK must be NOT NULL.- Returns:
- True, if the column must be NOT NULL before FK to it can be made
-
requiresNotNullUnique
boolean requiresNotNullUnique()
Determines, if the DB requires a NOT NULL constraint before an UQ can be created for the field.- Returns:
- True, if a field participating in UNIQUE constraint must be NOT NULL
-
supportedForeignKeyOnUpdateValues
java.lang.String[] supportedForeignKeyOnUpdateValues()
-
supportedForeignKeyOnDeleteValues
java.lang.String[] supportedForeignKeyOnDeleteValues()
-
getUpdateRuleAction
java.lang.String getUpdateRuleAction(int actionCode)
Returns a string representation of the action code for update rule in a FK.- Parameters:
actionCode
- The action code- Returns:
- The string representation of the action code
-
getDeleteRuleAction
java.lang.String getDeleteRuleAction(int actionCode)
Returns a string representation of the action code for delete rule in a FK.- Parameters:
actionCode
- The action code- Returns:
- The string representation of the action code
-
supportedIndexTypes
java.lang.String[] supportedIndexTypes()
-
prepareDefaultFromDatabaseMetadata
java.lang.String prepareDefaultFromDatabaseMetadata(java.lang.String value, DBDatabaseInfo.ColumnSQLType colType)
Convert the default value read from the JDBC metadata data into the real value. Each database has its own quirks in how the default is returned- Parameters:
value
- The default valuecolType
- The column type- Returns:
- The real converted value
-
isSupportsSchemas
boolean isSupportsSchemas()
-
getCartridgeOwner
java.lang.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.- Returns:
- The owner
-
isCartridgeJChemVersionCurrent
java.lang.Integer isCartridgeJChemVersionCurrent()
Compare the JChem version to the JChem cartridge to the one used by the JChem version that is being used here.- 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
-
isCartridgeJChemTableVersionCurrent
java.lang.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 recognized then the JChem versions are compared.- 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.
-
getJChemCartServerJChemTableVersion
java.lang.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.- Returns:
- The cartridge JChem table version
-
getJChemCartServerJChemVersion
java.lang.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.- Returns:
- The JChem version
-
fixNativeType
java.lang.String fixNativeType(java.lang.String nativeType)
Convert the native type to its correct form (adjust for Oracle quirks!).- Parameters:
nativeType
-- Returns:
- The corrected native type
-
convertNamesToUpperCase
boolean convertNamesToUpperCase()
Informs whether used DB platform uses upper case for names.- Returns:
true
if db platform defines propertymetadata-convertNamesToUpperCase
and that property is set to "true" (ignoring case). Otherwise returnsfalse
.
-
convertNamesToLowerCase
boolean convertNamesToLowerCase()
Informs whether used DB platform uses lower case for names.- Returns:
true
if db platform defines propertymetadata-convertNamesToLowerCase
and that property is set to "true" (ignoring case). Otherwise returnsfalse
.- Since:
- 15.12.28
-
-