com.im.commons.db 5.9.2

com.im.commons.db.ddl
Interface DBDatabaseInfo

All Superinterfaces:
Serializable
All Known Implementing Classes:
AbstractDBInfo

public interface DBDatabaseInfo
extends 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. .


Nested Class Summary
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 types
static class DBDatabaseInfo.ResizingSupported
          Enumeration of values for whether a database column can be resized.
 
Field Summary
static String ARRAY
           
static String BIGINT
           
static String BINARY
           
static String BIT
           
static String BLOB
           
static String BOOLEAN
           
static String CART_PROP_JChemPropertiesTable
           
static String CART_PROP_TableType
           
static String CHAR
           
static String CLOB
           
static String DATALINK
           
static String DATE
           
static String DECIMAL
           
static String DEFAULT_JCHEMPROPERTIES_TABLE_NAME
           
static String DISTINCT
           
static String DOUBLE
           
static String FLOAT
           
static String INDEX_UNIQUE
          Constant type for the unique index.
static String INT
           
static String INTEGER
           
static String JAVA_OBJECT
           
static String LONGVARBINARY
           
static String LONGVARCHAR
           
static String NULL
           
static String NUMBER
           
static String NUMERIC
           
static String NVARCHAR
           
static String NVARCHAR2
           
static String OTHER
           
static String REAL
           
static String REF
           
static String SMALLINT
           
static String STRUCT
           
static String TIME
           
static String TIMESTAMP
           
static String TINYINT
           
static String VARBINARY
           
static String VARCHAR
           
static String VARCHAR2
           
 
Method Summary
 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.
 boolean isSupportsSchemas()
           
 DBDatabaseInfo.NativeType nativeType(int jdbcType, String nativeType)
          Create a native type.
 DBDatabaseInfo.NativeType nativeType(int jdbcType, String nativeType, int size)
          Create a native type.
 DBDatabaseInfo.NativeType nativeType(int jdbcType, String nativeType, int size, int scale)
          Create a native type.
 DBDatabaseInfo.NativeType nativeType(String type)
          Create the NativeType for the specified column type.
 String prepareDefaultFromDatabaseMetadata(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.
 String[] supportedForeignKeyOnDeleteValues()
           
 String[] supportedForeignKeyOnUpdateValues()
           
 String[] supportedIndexTypes()
           
 boolean supportsOperation(DBDatabaseInfo.DatabaseOperation op)
          Is this operation supported by the database.
 

Field Detail

DEFAULT_JCHEMPROPERTIES_TABLE_NAME

static final String DEFAULT_JCHEMPROPERTIES_TABLE_NAME
See Also:
Constant Field Values

CART_PROP_JChemPropertiesTable

static final String CART_PROP_JChemPropertiesTable
See Also:
Constant Field Values

CART_PROP_TableType

static final String CART_PROP_TableType
See Also:
Constant Field Values

INDEX_UNIQUE

static final String INDEX_UNIQUE
Constant type for the unique index.

See Also:
Constant Field Values

ARRAY

static final String ARRAY
See Also:
Constant Field Values

BIGINT

static final String BIGINT
See Also:
Constant Field Values

BINARY

static final String BINARY
See Also:
Constant Field Values

BIT

static final String BIT
See Also:
Constant Field Values

BLOB

static final String BLOB
See Also:
Constant Field Values

BOOLEAN

static final String BOOLEAN
See Also:
Constant Field Values

CHAR

static final String CHAR
See Also:
Constant Field Values

CLOB

static final String CLOB
See Also:
Constant Field Values

DATALINK

static final String DATALINK
See Also:
Constant Field Values

DATE

static final String DATE
See Also:
Constant Field Values

DECIMAL

static final String DECIMAL
See Also:
Constant Field Values

DISTINCT

static final String DISTINCT
See Also:
Constant Field Values

DOUBLE

static final String DOUBLE
See Also:
Constant Field Values

FLOAT

static final String FLOAT
See Also:
Constant Field Values

INT

static final String INT
See Also:
Constant Field Values

INTEGER

static final String INTEGER
See Also:
Constant Field Values

JAVA_OBJECT

static final String JAVA_OBJECT
See Also:
Constant Field Values

LONGVARBINARY

static final String LONGVARBINARY
See Also:
Constant Field Values

LONGVARCHAR

static final String LONGVARCHAR
See Also:
Constant Field Values

NULL

static final String NULL
See Also:
Constant Field Values

NUMERIC

static final String NUMERIC
See Also:
Constant Field Values

NUMBER

static final String NUMBER
See Also:
Constant Field Values

NVARCHAR

static final String NVARCHAR
See Also:
Constant Field Values

NVARCHAR2

static final String NVARCHAR2
See Also:
Constant Field Values

OTHER

static final String OTHER
See Also:
Constant Field Values

REAL

static final String REAL
See Also:
Constant Field Values

REF

static final String REF
See Also:
Constant Field Values

SMALLINT

static final String SMALLINT
See Also:
Constant Field Values

STRUCT

static final String STRUCT
See Also:
Constant Field Values

TIME

static final String TIME
See Also:
Constant Field Values

TIMESTAMP

static final String TIMESTAMP
See Also:
Constant Field Values

TINYINT

static final String TINYINT
See Also:
Constant Field Values

VARBINARY

static final String VARBINARY
See Also:
Constant Field Values

VARCHAR

static final String VARCHAR
See Also:
Constant Field Values

VARCHAR2

static final String VARCHAR2
See Also:
Constant Field Values
Method Detail

getDBIdentifierQuoteString

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

Set<DBDatabaseInfo.DatabaseOperation> getUnsupportedDatabaseOperations()

getMaxElementsInList

int getMaxElementsInList()

getSQLWriter

SQLWriter getSQLWriter()

getSQLElementFactory

SQLElementFactory getSQLElementFactory()

convertAndWriteVariable

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.


createBindVariable

Object createBindVariable(String clsName,
                          DBDatabaseInfo.ColumnSQLType columnType,
                          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(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,
                                     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 name DBDatabaseInfo.ColumnSQLType

nativeType

DBDatabaseInfo.NativeType nativeType(int jdbcType,
                                     String nativeType,
                                     int size)
Create a native type. Scale is not defined.

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

nativeType

DBDatabaseInfo.NativeType nativeType(int jdbcType,
                                     String nativeType,
                                     int size,
                                     int scale)
Create a native type.

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

availableNativeTypesForColumnType

DBDatabaseInfo.NativeType[] availableNativeTypesForColumnType(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

String[] supportedForeignKeyOnUpdateValues()

supportedForeignKeyOnDeleteValues

String[] supportedForeignKeyOnDeleteValues()

getUpdateRuleAction

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

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

String[] supportedIndexTypes()

prepareDefaultFromDatabaseMetadata

String prepareDefaultFromDatabaseMetadata(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 value
colType - The column type
Returns:
The real converted value

isSupportsSchemas

boolean isSupportsSchemas()

getCartridgeOwner

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

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
See Also:
VersionInfo

isCartridgeJChemTableVersionCurrent

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.
See Also:
VersionInfo

getJChemCartServerJChemTableVersion

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
See Also:
VersionInfo

getJChemCartServerJChemVersion

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
See Also:
VersionInfo

fixNativeType

String fixNativeType(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:
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