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
    • 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()
      • getMaxElementsInList

        int getMaxElementsInList()
      • 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 name DBDatabaseInfo.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 name DBDatabaseInfo.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 name DBDatabaseInfo.ColumnSQLType
        size - The size of the type
        scale - 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 value
        colType - 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 property metadata-convertNamesToUpperCase and that property is set to "true" (ignoring case). Otherwise returns false.
      • convertNamesToLowerCase

        boolean convertNamesToLowerCase()
        Informs whether used DB platform uses lower case for names.
        Returns:
        true if db platform defines property metadata-convertNamesToLowerCase and that property is set to "true" (ignoring case). Otherwise returns false.
        Since:
        15.12.28