Package com.im.commons.db.ddl
Interface DBDatabaseInfo
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
AbstractDBInfo
public interface DBDatabaseInfo extends java.io.SerializableProvides 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.ResizingSupportedThese 2 enums should somehow be merged. .- Author:
- Tim Dudgeon
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classDBDatabaseInfo.ColumnSizingDefinition of sizing characteristics of column length or scale.static classDBDatabaseInfo.ColumnSQLTypeColumn native types.static classDBDatabaseInfo.DatabaseOperationTypes of database operations.static interfaceDBDatabaseInfo.NativeTypeRepresents a database column native type.static classDBDatabaseInfo.PKTypeSupported primary key typesstatic classDBDatabaseInfo.ResizingSupportedEnumeration of values for whether a database column can be resized.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringARRAYstatic java.lang.StringBIGINTstatic java.lang.StringBINARYstatic java.lang.StringBITstatic java.lang.StringBLOBstatic java.lang.StringBOOLEANstatic java.lang.StringCART_PROP_JChemPropertiesTablestatic java.lang.StringCART_PROP_TableTypestatic java.lang.StringCHARstatic java.lang.StringCLOBstatic java.lang.StringDATALINKstatic java.lang.StringDATEstatic java.lang.StringDECIMALstatic java.lang.StringDEFAULT_JCHEMPROPERTIES_TABLE_NAMEstatic java.lang.StringDISTINCTstatic java.lang.StringDOUBLEstatic java.lang.StringFLOATstatic java.lang.StringINDEX_UNIQUEConstant type for the unique index.static java.lang.StringINTstatic java.lang.StringINTEGERstatic java.lang.StringJAVA_OBJECTstatic java.lang.StringLONGVARBINARYstatic java.lang.StringLONGVARCHARstatic java.lang.StringNCHARstatic java.lang.StringNULLstatic java.lang.StringNUMBERstatic java.lang.StringNUMERICstatic java.lang.StringNVARCHARstatic java.lang.StringNVARCHAR2static java.lang.StringOTHERstatic java.lang.StringREALstatic java.lang.StringREFstatic java.lang.StringROWIDstatic java.lang.StringSMALLINTstatic java.lang.StringSTRUCTstatic java.lang.StringTIMEstatic java.lang.StringTIMESTAMPstatic java.lang.StringTINYINTstatic java.lang.StringVARBINARYstatic java.lang.StringVARCHARstatic java.lang.StringVARCHAR2
-
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.StringconvertAndWriteVariable(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.booleanconvertNamesToLowerCase()Informs whether used DB platform uses lower case for names.booleanconvertNamesToUpperCase()Informs whether used DB platform uses upper case for names.java.lang.ObjectcreateBindVariable(java.lang.String clsName, DBDatabaseInfo.ColumnSQLType columnType, java.lang.Object var)create a bind variable that can be used in a PreparedStatment.java.lang.StringfixNativeType(java.lang.String nativeType)Convert the native type to its correct form (adjust for Oracle quirks!).java.lang.StringgetCartridgeOwner()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.StringgetDBIdentifierQuoteString()Get the identifier needed to quote identifiers (e..g column names) for this DB.DBTypegetDBType()java.lang.StringgetDeleteRuleAction(int actionCode)Returns a string representation of the action code for delete rule in a FK.java.lang.StringgetJChemCartServerJChemTableVersion()Get the index version number used by the cartridge.java.lang.StringgetJChemCartServerJChemVersion()Get the JChem version number used by the cartridge.org.springframework.jdbc.support.lob.LobHandlergetLobHandler()intgetMaxColumnNameLength()Retrieves the maximum number of characters this database allows for a column name.intgetMaxElementsInList()intgetMaxIndexNameLength()Retrieves the maximum number of characters this database allows for a index name.intgetMaxTableNameLength()Retrieves the maximum number of characters this database allows in a table name.SQLWritergetSQLWriter()java.util.Set<DBDatabaseInfo.DatabaseOperation>getUnsupportedDatabaseOperations()java.lang.StringgetUpdateRuleAction(int actionCode)Returns a string representation of the action code for update rule in a FK.java.lang.IntegerisCartridgeJChemTableVersionCurrent()Compare the table version used by the cartridge to the one used by JChem.java.lang.IntegerisCartridgeJChemVersionCurrent()Compare the JChem version to the JChem cartridge to the one used by the JChem version that is being used here.booleanisSupportsSchemas()DBDatabaseInfo.NativeTypenativeType(int jdbcType, java.lang.String nativeType)Create a native type.DBDatabaseInfo.NativeTypenativeType(int jdbcType, java.lang.String nativeType, int size)Create a native type.DBDatabaseInfo.NativeTypenativeType(int jdbcType, java.lang.String nativeType, int size, int scale)Create a native type.DBDatabaseInfo.NativeTypenativeType(java.lang.String type)Create the NativeType for the specified column type.java.lang.StringprepareDefaultFromDatabaseMetadata(java.lang.String value, DBDatabaseInfo.ColumnSQLType colType)Convert the default value read from the JDBC metadata data into the real value.booleanrequiresNotNullDefault()Determines if it is legal to declare a column NOT NULL while giving no default value.booleanrequiresNotNullDefault(DBDatabaseInfo.ColumnSQLType type)Determines if it is legal to declare a column NOT NULL while giving no default value.booleanrequiresNotNullFK()Determines, if the columns participating in FK must be NOT NULL.booleanrequiresNotNullUnique()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()booleansupportsOperation(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.ColumnSQLTypesize- 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.ColumnSQLTypesize- 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:
trueif db platform defines propertymetadata-convertNamesToUpperCaseand that property is set to "true" (ignoring case). Otherwise returnsfalse.
-
convertNamesToLowerCase
boolean convertNamesToLowerCase()
Informs whether used DB platform uses lower case for names.- Returns:
trueif db platform defines propertymetadata-convertNamesToLowerCaseand that property is set to "true" (ignoring case). Otherwise returnsfalse.- Since:
- 15.12.28
-
-