Class AbstractDatabaseType

java.lang.Object
org.ofbiz.core.entity.jdbc.dbtype.AbstractDatabaseType
All Implemented Interfaces:
DatabaseType, ReservedKeywordsAware
Direct Known Subclasses:
AbstractPostgresDatabaseType, Hsql233DatabaseType, HsqlDatabaseType, Oracle10GDatabaseType, SapDB76DatabaseType, SapDBDatabaseType, SimpleDatabaseType

public abstract class AbstractDatabaseType extends Object implements DatabaseType
  • Field Details

    • CHANGE_COLUMN_TYPE_CLAUSE_STRUCTURE_STANDARD_ALTER_COLUMN

      protected static final String CHANGE_COLUMN_TYPE_CLAUSE_STRUCTURE_STANDARD_ALTER_COLUMN
      See Also:
    • CHANGE_COLUMN_TYPE_CLAUSE_STRUCTURE_STANDARD_MODIFY

      protected static final String CHANGE_COLUMN_TYPE_CLAUSE_STRUCTURE_STANDARD_MODIFY
      See Also:
    • DROP_INDEX_SCHEMA_DOT_INDEX

      protected static final String DROP_INDEX_SCHEMA_DOT_INDEX
      See Also:
    • DROP_INDEX_SCHEMA_DOT_TABLE_DOT_INDEX

      protected static final String DROP_INDEX_SCHEMA_DOT_TABLE_DOT_INDEX
      See Also:
    • ALTER_TABLE_DROP_INDEX

      protected static final String ALTER_TABLE_DROP_INDEX
      See Also:
    • STANDARD_SELECT_FOR_UPDATE_SYNTAX

      protected static final String STANDARD_SELECT_FOR_UPDATE_SYNTAX
      See Also:
  • Constructor Details

    • AbstractDatabaseType

      protected AbstractDatabaseType(String name, String fieldTypeName, String[] productNamePrefix, int constraintNameClipLength)
    • AbstractDatabaseType

      protected AbstractDatabaseType(String name, String fieldTypeName, String[] productNamePrefix)
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface DatabaseType
      Returns:
      A human readable version of the database type name
    • getFieldTypeName

      public String getFieldTypeName()
      Specified by:
      getFieldTypeName in interface DatabaseType
      Returns:
      The value that should be used for the field-type-name for a database of this type.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getSchemaName

      public String getSchemaName(Connection con)
      Description copied from interface: DatabaseType
      Returns the name of the connected schema.
      Specified by:
      getSchemaName in interface DatabaseType
      Parameters:
      con - the connection for which to return the schema
      Returns:
      null if a schema name is not available
    • getConstraintNameClipLength

      public int getConstraintNameClipLength()
      Specified by:
      getConstraintNameClipLength in interface DatabaseType
    • matchesConnection

      public abstract boolean matchesConnection(Connection con) throws SQLException
      Checks whether the connection object passed in matches the database type represented by this instance of the DatabaseType class.
      Specified by:
      matchesConnection in interface DatabaseType
      Returns:
      true if the Connection matches this DatabaseType instance.
      Throws:
      SQLException
    • registerWithFactory

      protected void registerWithFactory()
      Register this database type with DatabaseTypeFactory
      See Also:
    • versionGreaterThanOrEqual

      protected static boolean versionGreaterThanOrEqual(int major1, int minor1, int major2, int minor2)
      Compares two version numbers and returns true if the first version number is greater than the second
      Parameters:
      major1 - First major version number for comparison
      minor1 - First minor version number for comparison
      major2 - Second major version number for comparison
      minor2 - Second minor version number for comparison
      Returns:
      True if (major1, minor1) > (major2, minor2) otherwise false
    • productNamesMatch

      protected static boolean productNamesMatch(String productNamePrefix, String testName)
    • isProductNameInPrefixList

      protected static boolean isProductNameInPrefixList(String[] productNamePrefixes, String productName)
    • productNameMatches

      protected boolean productNameMatches(Connection con) throws SQLException
      Throws:
      SQLException
    • versionGreaterThanOrEqual

      protected boolean versionGreaterThanOrEqual(Connection con, int majorVersion, int minorVersion) throws SQLException
      Throws:
      SQLException
    • versionLessThanOrEqual

      protected boolean versionLessThanOrEqual(Connection con, int majorVersion, int minorVersion) throws SQLException
      Throws:
      SQLException
    • getChangeColumnTypeStructure

      protected String getChangeColumnTypeStructure()
      Returns:
      a format string to compose an SQL query to change a column in DB.
    • getChangeColumnTypeSQL

      public final String getChangeColumnTypeSQL(String tableName, String columnName, String targetSqlType)
      Builds a DB-specific SQL statement to update a column's type.
      Specified by:
      getChangeColumnTypeSQL in interface DatabaseType
      Parameters:
      tableName - the name of the table to be changed.
      columnName - the name of the column to be changed.
      targetSqlType - the target SQL type of the column.
      Returns:
      the SQL text to change the column, or null, if not supported.
    • getDropIndexStructure

      public String getDropIndexStructure()
      Returns:
      a format string to compose an SQL query to drop index in DB.
    • getDropIndexSQL

      public String getDropIndexSQL(String schemaName, String tableName, String indexName)
      Builds a DB-specific SQL statement for dropping index.
      Specified by:
      getDropIndexSQL in interface DatabaseType
      Parameters:
      schemaName - the of the schema containing table.
      tableName - the name of the table to be changed.
      indexName - the name of the index to be dropped.
      Returns:
      the SQL text to drop the index.
    • initialize

      public DatabaseType initialize(Connection con)
      Specified by:
      initialize in interface DatabaseType
    • getReservedKeywords

      public Set<String> getReservedKeywords()
      Specified by:
      getReservedKeywords in interface ReservedKeywordsAware
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object