org.jpox.store.rdbms.adapter
Class DatabaseAdapter

java.lang.Object
  extended by org.jpox.store.mapped.AbstractDatastoreAdapter
      extended by org.jpox.store.rdbms.adapter.DatabaseAdapter
All Implemented Interfaces:
org.jpox.store.mapped.DatastoreAdapter, org.jpox.store.mapped.expression.ExpressionConversionAdapter, org.jpox.store.mapped.expression.ExpressionLogicSetAdapter, org.jpox.store.mapped.expression.ExpressionMethodAdapter, org.jpox.store.mapped.expression.ExpressionOperatorAdapter, org.jpox.store.mapped.expression.ExpressionPatternAdapter, org.jpox.store.mapped.expression.ExpressionSupportedFeaturesAdapter, RDBMSAdapter
Direct Known Subclasses:
DB2Adapter, DerbyAdapter, FirebirdAdapter, H2Adapter, HSQLAdapter, InformixAdapter, McKoiAdapter, MSSQLServerAdapter, MySQLAdapter, OracleAdapter, PointbaseAdapter, PostgreSQLAdapter, SAPDBAdapter, SybaseAdapter

public class DatabaseAdapter
extends org.jpox.store.mapped.AbstractDatastoreAdapter
implements RDBMSAdapter

Provides methods for adapting SQL language elements to a specific vendor's database. A database adapter is primarily used to map generic JDBC data types and SQL identifiers to specific types/identifiers suitable for the database in use.

Each database adapter corresponds to a particular combination of database, database version, driver, and driver version, as provided by the driver's own metadata. Database adapters cannot be constructed directly, but must be obtained using the RDBMSAdapterFactory class.

Version:
$Revision: 1.141 $
See Also:
RDBMSAdapterFactory, DatabaseMetaData

Nested Class Summary
 class DatabaseAdapter.JDBCTypeInfo
          Convenience container for JDBC type information taken from the JDBC driver.
 
Field Summary
protected  java.lang.String catalogSeparator
          The String used to separate catalog and table name.
protected  int driverMajorVersion
          The major version number of the underlying driver.
protected  int driverMinorVersion
          The minor version number of the underlying driver.
protected  java.lang.String driverName
          the JDBC driver name
protected  java.lang.String driverVersion
          the JDBC driver version
protected static org.jpox.util.Localiser LOCALISER
           
protected  int maxColumnNameLength
          The maximum length to be used for a column name.
protected  int maxConstraintNameLength
          The maximum length to be used for a table constraint name.
protected  int maxIndexNameLength
          The maximum length to be used for an index name.
protected  int maxTableNameLength
          The maximum length to be used for a table name.
protected  boolean storesLowerCaseIdentifiers
           
protected  boolean storesLowerCaseQuotedIdentifiers
           
protected  boolean storesMixedCaseIdentifiers
           
protected  boolean storesMixedCaseQuotedIdentifiers
           
protected  boolean storesMixedCaseQuotedSensitiveIdentifiers
           
protected  boolean storesMixedCaseSensitiveIdentifiers
           
protected  boolean storesUpperCaseIdentifiers
           
protected  boolean storesUpperCaseQuotedIdentifiers
           
protected  boolean supportsCatalogsInTableDefinitions
          true if the database supports catalogs in table definition
protected  boolean supportsSchemasInTableDefinitions
          true if the database supports schemas in table definition
protected  boolean supportsStatementBatching
          Whether the adapter supports batching of statements.
protected  java.util.HashMap typesByTypeNumber
          JDBCTypeInfo, keyed by the type number.
 
Fields inherited from class org.jpox.store.mapped.AbstractDatastoreAdapter
datastoreMajorVersion, datastoreMinorVersion, datastoreProductName, datastoreProductVersion, datastoreRevisionVersion, identifierQuoteString, LOCALISER_BASE, mappingManager, reservedKeywords
 
Constructor Summary
protected DatabaseAdapter(java.sql.DatabaseMetaData metadata)
          Constructs a database adapter based on the given JDBC metadata.
 
Method Summary
 org.jpox.store.mapped.expression.NumericExpression absMethod(org.jpox.store.mapped.expression.ScalarExpression expr)
          Returns the appropriate SQL expression for the JDOQL Math.abs(EXPRESSION) method.
 org.jpox.store.mapped.expression.NumericExpression acosMethod(org.jpox.store.mapped.expression.ScalarExpression expr)
          Returns the appropriate SQL expression for the JDOQL Math.acos(EXPRESSION) method.
protected  void addTypeInfo(short jdbcType, TypeInfo ti, boolean addIfNotPresent)
          Convenience method for use by overriding adapters to add their own fake types in.
 org.jpox.store.mapped.expression.NumericExpression asinMethod(org.jpox.store.mapped.expression.ScalarExpression expr)
          Returns the appropriate SQL expression for the JDOQL Math.asin(EXPRESSION) method.
 org.jpox.store.mapped.expression.NumericExpression atanMethod(org.jpox.store.mapped.expression.ScalarExpression expr)
          Returns the appropriate SQL expression for the JDOQL Math.atan(EXPRESSION) method.
 java.lang.String cartersianProduct(org.jpox.store.mapped.expression.LogicSetExpression Y)
          Generates a expression that represents the cartesian product of two sets: X and Y.
 org.jpox.store.mapped.expression.NumericExpression ceilMethod(org.jpox.store.mapped.expression.ScalarExpression expr)
          Returns the appropriate SQL expression for the JDOQL ceil(EXPRESSION) method.
 void closeConnection(java.sql.Connection conn)
          Method to close a Connection to the datastore.
 org.jpox.store.mapped.expression.ScalarExpression concatOperator(org.jpox.store.mapped.expression.ScalarExpression operand1, org.jpox.store.mapped.expression.ScalarExpression operand2)
           If only one operand expression is of type String, then string conversion is performed on the other operand to produce a string at run time.
 org.jpox.store.mapped.expression.NumericExpression cosMethod(org.jpox.store.mapped.expression.ScalarExpression expr)
          Returns the appropriate SQL expression for the JDOQL Math.cos(EXPRESSION) method.
 boolean createIndexesBeforeForeignKeys()
          Whether to create indexes before foreign keys.
 org.jpox.store.mapped.expression.BooleanExpression endsWithMethod(org.jpox.store.mapped.expression.ScalarExpression leftOperand, org.jpox.store.mapped.expression.ScalarExpression rightOperand)
          Returns whether this string ends with the specified string.
 org.jpox.store.mapped.expression.NumericExpression expMethod(org.jpox.store.mapped.expression.ScalarExpression expr)
          Returns the appropriate SQL expression for the JDOQL Math.exp(EXPRESSION) method.
 org.jpox.store.mapped.expression.NumericExpression floorMethod(org.jpox.store.mapped.expression.ScalarExpression expr)
          Returns the appropriate SQL expression for the JDOQL Math.floor(EXPRESSION) method.
 java.lang.String getAddCandidateKeyStatement(CandidateKey ck, org.jpox.store.mapped.IdentifierFactory factory)
          Returns the appropriate SQL to add a candidate key to its table.
 java.lang.String getAddColumnStatement(org.jpox.store.mapped.DatastoreContainerObject table, Column col)
          Accessor for the SQL statement to add a column to a table.
 java.lang.String getAddForeignKeyStatement(ForeignKey fk, org.jpox.store.mapped.IdentifierFactory factory)
          Returns the appropriate SQL to add a foreign key to its table.
 java.lang.String getAddPrimaryKeyStatement(PrimaryKey pk, org.jpox.store.mapped.IdentifierFactory factory)
          Returns the appropriate SQL to add a primary key to its table.
 java.lang.String getAutoIncrementKeyword()
          Accessor for the autoincrementing keyword for generating DDLs.
 java.lang.String getAutoIncrementStmt(Table table, java.lang.String columnName)
          Accessor for the autoincrementing sql statement for this datastore.
 java.lang.String getCatalogName(java.sql.Connection conn)
          Accessor for the Catalog Name for this datastore.
 java.lang.String getCatalogSeparator()
          Accessor for the catalog separator.
 boolean getCharColumnsPaddedWithSpaces()
          Some databases store character strings in CHAR(XX) columns and when read back in have been padded with spaces.
 java.lang.String getCheckConstraintForValues(org.jpox.store.mapped.DatastoreIdentifier identifier, org.jpox.store.mapped.expression.ScalarExpression[] values, boolean nullable)
          Creates a CHECK constraint definition based on the given values e.g.
 java.sql.ResultSet getColumns(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema, java.lang.String table)
          Accessor for table and column information for a catalog/schema in this datastore.
 java.sql.ResultSet getColumns(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String columnNamePattern)
          Accessor for table and column information for a catalog/schema in this datastore.
 java.sql.Connection getConnection(ConnectionProvider connProvider, javax.sql.DataSource[] ds, int isolationLevel)
          Accessor for a Connection to the datastore.
 java.lang.String getContinuationString()
          Continuation string to use where the SQL statement goes over more than 1 line.
 java.lang.String getCreateIndexStatement(Index idx, org.jpox.store.mapped.IdentifierFactory factory)
          Returns the appropriate SQL to add an index to its table.
 java.lang.String getCreateTableStatement(TableImpl table, Column[] columns, java.util.Properties props)
          Returns the appropriate SQL to create the given table having the given columns.
 org.jpox.store.mapped.expression.ScalarExpression getCurrentDateMethod(org.jpox.store.mapped.expression.QueryExpression qs)
          Method to return an expression for the current date in the datastore.
 org.jpox.store.mapped.expression.ScalarExpression getCurrentTimeMethod(org.jpox.store.mapped.expression.QueryExpression qs)
          Method to return an expression for the current time in the datastore.
 org.jpox.store.mapped.expression.ScalarExpression getCurrentTimestampMethod(org.jpox.store.mapped.expression.QueryExpression qs)
          Method to return an expression for the current timestamp in the datastore.
 java.lang.String getDatastoreDateStatement()
          Accessor for a statement that will return the statement to use to get the datastore date.
 org.jpox.store.mapped.expression.NumericExpression getDayMethod(org.jpox.store.mapped.expression.SqlTemporalExpression date)
          Returns the appropriate SQL expression for the JDOQL Date.getDay() method.
 int getDriverMajorVersion()
          Accessor for the JDBC driver major version
 int getDriverMinorVersion()
          Accessor for the JDBC driver minor version
 java.lang.String getDropTableStatement(org.jpox.store.mapped.DatastoreContainerObject table)
          Returns the appropriate SQL to drop the given table.
 java.lang.String getDropViewStatement(ViewImpl view)
          Returns the appropriate SQL to drop the given view.
 java.lang.String getEscapeCharacter()
          The character for escaping characters in pattern expressions.
 org.jpox.store.mapped.expression.ScalarExpression getEscapedPatternExpression(org.jpox.store.mapped.expression.ScalarExpression patternExpression)
          The pattern string for representing one character.
 java.lang.String getEscapePatternExpression()
          The character for escaping characters in pattern expressions.
 java.sql.ResultSet getExistingIndexes(java.sql.Connection conn, java.sql.DatabaseMetaData dmd, java.lang.String catalog, java.lang.String schema, java.lang.String table)
          Provide the existing indexes in the database for the table
 org.jpox.store.mapped.expression.NumericExpression getHourMethod(org.jpox.store.mapped.expression.SqlTemporalExpression time)
          Returns the appropriate SQL expression for the JDOQL Time.getHour() method.
 java.lang.String getInsertStatementForNoColumns(Table table)
          Method to return the INSERT statement to use when inserting into a table that has no columns specified.
 int getMaxColumnNameLength()
          Accessor for the maximum column name length permitted on this datastore.
 int getMaxConstraintNameLength()
          Accessor for the maximum constraint name length permitted on this datastore.
 int getMaxForeignKeys()
          Accessor for the maximum foreign keys by table permitted for this datastore.
 int getMaxIndexes()
          Accessor for the maximum indexes by schema permitted for this datastore.
 int getMaxIndexNameLength()
          Accessor for the maximum index name length permitted on this datastore.
 int getMaxTableNameLength()
          Accessor for the maximum table name length permitted on this datastore.
 org.jpox.store.mapped.expression.NumericExpression getMinuteMethod(org.jpox.store.mapped.expression.SqlTemporalExpression time)
          Returns the appropriate SQL expression for the JDOQL Time.getMinute() method.
 org.jpox.store.mapped.expression.NumericExpression getMonthMethod(org.jpox.store.mapped.expression.SqlTemporalExpression date)
          Returns the appropriate SQL expression for the JDOQL Date.getMonth() method.
protected  org.jpox.store.mapped.mapping.MappingManager getNewMappingManager()
          Accessor for a new Mapping Manager
 java.lang.String getNewUUIDFunction()
          The function to creates a unique value of type uniqueidentifier.
 java.lang.String getNonAnsiInnerJoinWhereClause(java.lang.String col1, java.lang.String col2)
          Accessor for the WHERE clause to add to provide an INNER JOIN using non-ANSI syntax.
 java.lang.String getNonAnsiLeftOuterJoinWhereClause(java.lang.String col1, java.lang.String col2)
          Accessor for the WHERE clause to add to provide a LEFT OUTER JOIN using non-ANSI syntax.
 java.lang.String getNonAnsiRightOuterJoinWhereClause(java.lang.String col1, java.lang.String col2)
          Accessor for the WHERE clause to add to provide a RIGHT OUTER JOIN using non-ANSI syntax.
 java.lang.String getOperatorConcat()
          An operator in a string expression that concatenates two or more character or binary strings, columns, or a combination of strings and column names into one expression (a string operator).
 java.lang.String getPatternExpressionAnyCharacter()
          The pattern string for representing one character that is expanded in word searches.
 java.lang.String getPatternExpressionZeroMoreCharacters()
          The pattern string for representing zero or more characters that is expanded in word searches.
 boolean getPlaceWithOptionAfterFromClause()
          Determines whether the getSelectWithLockOption() is to be placed right before the FROM clause, or at the end of the statement
 boolean getPlaceWithOptionWithinJoinClauses()
          Determines whether lock option has to be placed within JOIN clauses as well.
 java.lang.String getRangeByLimitSelectClause(long offset, long count)
          Method to return the SQL to append to the SELECT clause of a SELECT statement to handle restriction of ranges using the LIMIT keyword.
 java.lang.String getRangeByLimitWhereClause(long offset, long count)
          Method to return the SQL to append to the WHERE clause of a SELECT statement to handle restriction of ranges using the LIMIT keyword.
 java.lang.String getRangeByRowNumberColumn()
          Method to return the column name to use when handling ranges via a rownumber on the select.
 int getRequiredTransactionIsolationLevel()
          Accessor for the "required" transaction isolation level if it has to be a certain value for this adapter.
 java.lang.String getSchemaName(java.sql.Connection conn)
          Accessor for the Schema Name for this datastore.
 org.jpox.store.mapped.expression.NumericExpression getSecondMethod(org.jpox.store.mapped.expression.SqlTemporalExpression time)
          Returns the appropriate SQL expression for the JDOQL Time.getSecond() method.
 java.lang.String getSelectNewUUIDStmt()
          The function to creates a unique value of type uniqueidentifier.
 java.lang.String getSelectWithLockOption()
          The option to specify in "SELECT ...
 java.lang.String getSequenceCreateStmt(java.lang.String sequence_name, java.lang.String min, java.lang.String max, java.lang.String start, java.lang.String increment, java.lang.String cache_size)
          Accessor for the sequence create statement for this datastore.
 java.lang.String getSequenceNextStmt(java.lang.String sequence_name)
          Accessor for the sequence statement to get the next id for this datastore.
 boolean getSupportsPersistOfUnassignedChar()
          Whether the database server supports persist of an unassigned character ("0x0").
 java.lang.String getSurrogateForEmptyStrings()
          Some databases, Oracle, treats an empty string (0 length) equals null
 java.sql.ResultSet getTables(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema)
          Accessor for table information for a catalog/schema in this datastore.
 int getTransactionIsolationForSchemaCreation()
          Accessor for the transaction isolation level to use during schema creation.
 TypeInfo getTypeInfo(int dataType)
          Returns type information for the database type that best implements the given JDBC type.
 int getUnlimitedLengthPrecisionValue(TypeInfo typeInfo)
          Returns the precision value to be used when creating string columns of "unlimited" length.
 org.jpox.store.mapped.expression.NumericExpression getYearMethod(org.jpox.store.mapped.expression.SqlTemporalExpression date)
          Returns the appropriate SQL expression for the JDOQL Date.getYear() method.
 boolean includeOrderByColumnsInSelect()
          Whether to include ORDER BY columns in a SELECT.
 org.jpox.store.mapped.expression.NumericExpression indexOfMethod(org.jpox.store.mapped.expression.ScalarExpression source, org.jpox.store.mapped.expression.ScalarExpression str, org.jpox.store.mapped.expression.NumericExpression from)
          Returns the appropriate SQL expression for the JDOQL String.indexOf() method.
 void initialiseDatastore(java.lang.Object conn)
          Creates the auxiliary functions/procedures in the schema
 boolean isIdentityFieldDataType(java.lang.String typeName)
          Verifies if the given typeName is auto incremented by the datastore.
 boolean isNullEqualsEmptyStrings()
          Some databases, Oracle, treats an empty string (0 length) equals null
 boolean isSQLKeyword(java.lang.String word)
          Tests if a given string is a SQL key word.
 boolean isStoresLowerCaseIdentifiers()
           
 boolean isStoresLowerCaseQuotedIdentifiers()
           
 boolean isStoresMixedCaseIdentifiers()
           
 boolean isStoresMixedCaseQuotedIdentifiers()
           
 boolean isStoresUpperCaseIdentifiers()
           
 boolean isStoresUpperCaseQuotedIdentifiers()
           
 boolean isValidPrimaryKeyType(int datatype)
          Method to return whether the specified JDBC type is valid for use in a PrimaryKey.
 java.util.Iterator iteratorReservedWords()
          Iterator for the reserved words constructed from the method DataBaseMetaData.getSQLKeywords + standard SQL reserved words
 java.util.Iterator iteratorTypeInfo()
          Iterator for the TypeInfo objects constructed from the method DataBaseMetaData.getTypeInfo
 org.jpox.store.mapped.expression.NumericExpression lengthMethod(org.jpox.store.mapped.expression.StringExpression str)
          Returns the appropriate SQL expression for the JDOQL String.length() method.
 void loadDatastoreMapping(org.jpox.plugin.PluginManager mgr, org.jpox.ClassLoaderResolver clr)
          Load the datastore mapping declared as Plug-in
 void logConfiguration()
          Convenience method to log the configuration of this datastore adapter.
 org.jpox.store.mapped.expression.NumericExpression logMethod(org.jpox.store.mapped.expression.ScalarExpression expr)
          Returns the appropriate SQL expression for the JDOQL Math.log(EXPRESSION) method.
 org.jpox.store.mapped.expression.BooleanExpression matchesMethod(org.jpox.store.mapped.expression.StringExpression text, org.jpox.store.mapped.expression.StringExpression pattern)
          Matches this to the argument expression pattern.
 ColumnInfo newColumnInfo(java.sql.ResultSet rs)
          A factory for ColumnInfo objects.
 ExportedKeyInfo newExportedKeyInfo(java.sql.ResultSet rs)
          A factory for ForeignKeyInfo objects.
 ForeignKeyInfo newForeignKeyInfo(java.sql.ResultSet rs)
          A factory for ForeignKeyInfo objects.
 org.jpox.store.mapped.expression.QueryExpression newQueryStatement(org.jpox.store.mapped.DatastoreContainerObject table, org.jpox.ClassLoaderResolver clr)
          Accessor for a new query statement.
 org.jpox.store.mapped.expression.QueryExpression newQueryStatement(org.jpox.store.mapped.DatastoreContainerObject table, org.jpox.store.mapped.DatastoreIdentifier rangeVar, org.jpox.ClassLoaderResolver clr)
          Accessor for a new query statement.
 org.jpox.store.mapped.expression.LogicSetExpression newTableExpression(org.jpox.store.mapped.expression.QueryExpression qs, org.jpox.store.mapped.DatastoreContainerObject table, org.jpox.store.mapped.DatastoreIdentifier rangeVar)
          Returns a new TableExpression object appropriate for this DBMS.
protected  TypeInfo newTypeInfo(java.sql.ResultSet rs)
          A factory for TypeInfo objects.
protected  java.util.Set parseKeywordList(java.lang.String list)
          Utility method to parse a list of keywords and split them out into words.
 boolean requiresColumnDefaultsInitialising()
          Accessor for whether the column defaults need initialising for this datastore
protected  void setDefaultTypeInfoForJDBCType(int jdbcType, java.lang.String defaultTypeName)
          Convenience method to set the default database type name for a particular JDBC type.
 org.jpox.store.mapped.expression.NumericExpression sinMethod(org.jpox.store.mapped.expression.ScalarExpression expr)
          Returns the appropriate SQL expression for the JDOQL Math.sin(EXPRESSION) method.
 org.jpox.store.mapped.expression.NumericExpression sqrtMethod(org.jpox.store.mapped.expression.ScalarExpression expr)
          Returns the appropriate SQL expression for the JDOQL Math.sqrt(EXPRESSION) method.
 org.jpox.store.mapped.expression.BooleanExpression startsWithMethod(org.jpox.store.mapped.expression.ScalarExpression source, org.jpox.store.mapped.expression.ScalarExpression str)
          Method to handle the starts with operation.
 org.jpox.store.mapped.expression.StringExpression substringMethod(org.jpox.store.mapped.expression.StringExpression str, org.jpox.store.mapped.expression.NumericExpression begin)
          Returns the appropriate SQL expression for the JDOQL String.substring(str,begin) method.
 org.jpox.store.mapped.expression.StringExpression substringMethod(org.jpox.store.mapped.expression.StringExpression str, org.jpox.store.mapped.expression.NumericExpression begin, org.jpox.store.mapped.expression.NumericExpression end)
          Returns the appropriate SQL expression for the JDOQL String.substring(str,begin,end) method.
 boolean supportsAlterTableDropConstraint()
          Whether this datastore supports ALTER TABLE DROP constraints
 boolean supportsAlterTableDropForeignKeyConstraint()
          Whether this datastore supports ALTER TABLE DROP FOREIGN KEY constraints
 boolean supportsAnalysisMethods()
          Accessor for whether the SQL extensions CUBE, ROLLUP are supported.
 boolean supportsAnsiJoinSyntax()
          Accessor for whether the RDBMS supports ANSI join syntax.
 boolean supportsAutoIncrementColumnTypeSpecification()
          Whether we support auto-increment/identity keys with column type specification.
 boolean supportsAutoIncrementKeysNullSpecification()
          Whether we support autoincrementing keys with nullability specification.
 boolean supportsBooleanComparison()
          Whether we support Boolean comparisons.
 boolean supportsCatalogsInTableDefinitions()
          Whether this datastore supports the use of the catalog name in SQL table definitions (DDL).
 boolean supportsCheckConstraintsInEndCreateStatements()
          Whether this datastore supports the use of CHECK after the column definitions in CREATE TABLE statements (DDL).
 boolean supportsCheckInCreateStatements()
          Whether this datastore supports the use of CHECK in CREATE TABLE statements (DDL).
 boolean supportsDefaultBeforeNullInColumnOptions()
          Whether any DEFAULT tag will be before any NULL/NOT NULL in the column options.
 boolean supportsDefaultKeywordInColumnOptions()
          Whether we support DEFAULT tag in CREATE TABLE statements
 boolean supportsDefaultKeywordWithNotNullInColumnOptions()
          Whether we support DEFAULT tag together with NOT NULL in CREATE TABLE statements.
 boolean supportsDeferredConstraints()
          Whether this datastore supports deferred constraints.
 boolean supportsDistinctWithSelectForUpdate()
          Whether this datastore supports using DISTINCT when using SELECT ...
 boolean supportsEscapeExpressionInLikePredicate()
          Whether this datastore supports the use of the escape expression in like predicates
 boolean supportsExistsSyntax()
          Whether the RDBMS supports use of EXISTS syntax.
 boolean supportsForeignKeyDeleteAction(ForeignKey.FKAction action)
          Whether this datastore supports the specified foreign key delete action
 boolean supportsForeignKeyUpdateAction(ForeignKey.FKAction action)
          Whether this datastore supports the specified foreign key update action
 boolean supportsLockWithSelectForUpdate()
          Whether this datastore supports SELECT ...
 boolean supportsNullsInCandidateKeys()
          Whether we support NULLs in candidate keys.
 boolean supportsNullsKeywordInColumnOptions()
          Whether the database support NULLs in the column options for table creation.
 boolean supportsPrimaryKeyInCreateStatements()
          Whether the datastore supports specification of the primary key in CREATE TABLE statements.
 boolean supportsProjectionInTableReferenceJoins()
          Whether this datastore supports "SELECT a.* FROM (SELECT * FROM TBL1 INNER JOIN TBL2 ON tbl1.x = tbl2.y ) a" If the database does not support the SQL statement generated is like "SELECT a.* FROM (TBL1 INNER JOIN TBL2 ON tbl1.x = tbl2.y ) a"
 boolean supportsSchemasInTableDefinitions()
          Whether this datastore supports the use of the schema name in SQL table definitions (DDL).
 boolean supportsSettingBlobUsingSetString()
          Accessor for whether setting a BLOB value allows use of PreparedStatement.setString()
 boolean supportsSettingClobUsingSetString()
          Accessor for whether setting a CLOB value allows use of PreparedStatement.setString()
 boolean supportsStatementBatching()
          Whether this datastore supports batching of statements.
 boolean supportsStatementGetGeneratedKeys()
          Whether the datastore supports Statement.getGeneratedKeys()
 boolean supportsTransactionIsolationLevel(int isolationLevel)
          Accessor for whether the adapter supports the transaction isolation level.
 boolean supportsUnionSyntax()
          Whether the RDBMS supports use of UNION syntax.
 boolean supportsUniqueConstraintsInEndCreateStatements()
          Whether this datastore supports the use of UNIQUE after the column definitions in CREATE TABLE statements (DDL).
 org.jpox.store.mapped.expression.NumericExpression tanMethod(org.jpox.store.mapped.expression.ScalarExpression expr)
          Returns the appropriate SQL expression for the JDOQL Math.tan(EXPRESSION) method.
 org.jpox.store.mapped.expression.NumericExpression toNumericExpression(org.jpox.store.mapped.expression.CharacterExpression expr)
          Returns the appropriate expression for the (int)'A' expression.
 java.lang.String toString()
           
 org.jpox.store.mapped.expression.StringExpression toStringExpression(org.jpox.store.mapped.expression.NumericExpression expr)
          A String conversion that converts a numeric expression to string.
 org.jpox.store.mapped.expression.StringExpression toStringExpression(org.jpox.store.mapped.expression.StringLiteral expr)
          A String conversion that converts a String literal to String expression.
 org.jpox.store.mapped.expression.StringExpression translateMethod(org.jpox.store.mapped.expression.ScalarExpression expr, org.jpox.store.mapped.expression.ScalarExpression toExpr, org.jpox.store.mapped.expression.ScalarExpression fromExpr)
          Method to translate all chars in this expression to the fromExpr which corresponds to toExpr.
 org.jpox.store.mapped.expression.StringExpression trimMethod(org.jpox.store.mapped.expression.StringExpression str, boolean leading, boolean trailing)
          Returns the appropriate SQL expression for a query "trim" method.
 boolean useUnionAll()
          Union combines the results of two or more queries into a single result set.
 
Methods inherited from class org.jpox.store.mapped.AbstractDatastoreAdapter
getAdapterTime, getDatastoreMajorVersion, getDatastoreMinorVersion, getIdentifierQuoteString, getMapping, getMapping, getMapping, getMapping, getMapping, getMappingManager, getMiliseconds, getTime, getVendorID, isBitReallyBoolean, isReservedKeyword, modOperator, supportsIdentityFields, supportsQueryFetchSize, supportsSequences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jpox.store.rdbms.adapter.RDBMSAdapter
getIdentifierQuoteString, supportsSequences
 
Methods inherited from interface org.jpox.store.mapped.DatastoreAdapter
getAdapterTime, getDatastoreMajorVersion, getDatastoreMinorVersion, getMapping, getMapping, getMapping, getMapping, getMappingManager, getVendorID, isBitReallyBoolean, isReservedKeyword, modOperator, supportsIdentityFields, supportsQueryFetchSize
 

Field Detail

LOCALISER

protected static final org.jpox.util.Localiser LOCALISER

driverName

protected java.lang.String driverName
the JDBC driver name


driverVersion

protected java.lang.String driverVersion
the JDBC driver version


driverMajorVersion

protected int driverMajorVersion
The major version number of the underlying driver.


driverMinorVersion

protected int driverMinorVersion
The minor version number of the underlying driver.


maxTableNameLength

protected int maxTableNameLength
The maximum length to be used for a table name.


maxConstraintNameLength

protected int maxConstraintNameLength
The maximum length to be used for a table constraint name.


maxIndexNameLength

protected int maxIndexNameLength
The maximum length to be used for an index name.


maxColumnNameLength

protected int maxColumnNameLength
The maximum length to be used for a column name.


supportsCatalogsInTableDefinitions

protected boolean supportsCatalogsInTableDefinitions
true if the database supports catalogs in table definition


supportsSchemasInTableDefinitions

protected boolean supportsSchemasInTableDefinitions
true if the database supports schemas in table definition


catalogSeparator

protected java.lang.String catalogSeparator
The String used to separate catalog and table name.


typesByTypeNumber

protected final java.util.HashMap typesByTypeNumber
JDBCTypeInfo, keyed by the type number. Allowing for overriding by RDBMS.


supportsStatementBatching

protected boolean supportsStatementBatching
Whether the adapter supports batching of statements.


storesLowerCaseIdentifiers

protected boolean storesLowerCaseIdentifiers

storesMixedCaseIdentifiers

protected boolean storesMixedCaseIdentifiers

storesUpperCaseIdentifiers

protected boolean storesUpperCaseIdentifiers

storesLowerCaseQuotedIdentifiers

protected boolean storesLowerCaseQuotedIdentifiers

storesMixedCaseQuotedIdentifiers

protected boolean storesMixedCaseQuotedIdentifiers

storesUpperCaseQuotedIdentifiers

protected boolean storesUpperCaseQuotedIdentifiers

storesMixedCaseSensitiveIdentifiers

protected boolean storesMixedCaseSensitiveIdentifiers

storesMixedCaseQuotedSensitiveIdentifiers

protected boolean storesMixedCaseQuotedSensitiveIdentifiers
Constructor Detail

DatabaseAdapter

protected DatabaseAdapter(java.sql.DatabaseMetaData metadata)
Constructs a database adapter based on the given JDBC metadata.

Parameters:
metadata - the database metadata.
Method Detail

logConfiguration

public void logConfiguration()
Convenience method to log the configuration of this datastore adapter.

Specified by:
logConfiguration in interface RDBMSAdapter

initialiseDatastore

public void initialiseDatastore(java.lang.Object conn)
Creates the auxiliary functions/procedures in the schema

Specified by:
initialiseDatastore in interface org.jpox.store.mapped.DatastoreAdapter
Parameters:
conn - the connection to the datastore

loadDatastoreMapping

public void loadDatastoreMapping(org.jpox.plugin.PluginManager mgr,
                                 org.jpox.ClassLoaderResolver clr)
Load the datastore mapping declared as Plug-in

Specified by:
loadDatastoreMapping in interface org.jpox.store.mapped.DatastoreAdapter
Overrides:
loadDatastoreMapping in class org.jpox.store.mapped.AbstractDatastoreAdapter
Parameters:
mgr - the PluginManager
clr - the ClassLoaderResolver

getDriverMajorVersion

public int getDriverMajorVersion()
Accessor for the JDBC driver major version

Returns:
The driver major version

getDriverMinorVersion

public int getDriverMinorVersion()
Accessor for the JDBC driver minor version

Returns:
The driver minor version

getMaxTableNameLength

public int getMaxTableNameLength()
Accessor for the maximum table name length permitted on this datastore.

Specified by:
getMaxTableNameLength in interface RDBMSAdapter
Returns:
Max table name length

getMaxForeignKeys

public int getMaxForeignKeys()
Accessor for the maximum foreign keys by table permitted for this datastore.

Specified by:
getMaxForeignKeys in interface RDBMSAdapter
Returns:
Max number of FKs for a table

getMaxIndexes

public int getMaxIndexes()
Accessor for the maximum indexes by schema permitted for this datastore.

Specified by:
getMaxIndexes in interface RDBMSAdapter
Returns:
Max number of indexes for a table

getMaxConstraintNameLength

public int getMaxConstraintNameLength()
Accessor for the maximum constraint name length permitted on this datastore.

Specified by:
getMaxConstraintNameLength in interface RDBMSAdapter
Returns:
Max constraint name length

getMaxIndexNameLength

public int getMaxIndexNameLength()
Accessor for the maximum index name length permitted on this datastore.

Specified by:
getMaxIndexNameLength in interface RDBMSAdapter
Returns:
Max index name length

getMaxColumnNameLength

public int getMaxColumnNameLength()
Accessor for the maximum column name length permitted on this datastore.

Specified by:
getMaxColumnNameLength in interface RDBMSAdapter
Returns:
Max column name length

iteratorTypeInfo

public java.util.Iterator iteratorTypeInfo()
Iterator for the TypeInfo objects constructed from the method DataBaseMetaData.getTypeInfo

Specified by:
iteratorTypeInfo in interface RDBMSAdapter
Returns:
an Iterator with org.jpox.store.rdbms.typeinfo.TypeInfo

iteratorReservedWords

public java.util.Iterator iteratorReservedWords()
Iterator for the reserved words constructed from the method DataBaseMetaData.getSQLKeywords + standard SQL reserved words

Specified by:
iteratorReservedWords in interface RDBMSAdapter
Returns:
an Iterator with a set of reserved words

addTypeInfo

protected void addTypeInfo(short jdbcType,
                           TypeInfo ti,
                           boolean addIfNotPresent)
Convenience method for use by overriding adapters to add their own fake types in.

Parameters:
jdbcType - The JDBC type
ti - The type info to use

setDefaultTypeInfoForJDBCType

protected void setDefaultTypeInfoForJDBCType(int jdbcType,
                                             java.lang.String defaultTypeName)
Convenience method to set the default database type name for a particular JDBC type. Sets the default to this if the type is found.

Parameters:
jdbcType - The JDBC type
defaultTypeName - The default database type name

newTypeInfo

protected TypeInfo newTypeInfo(java.sql.ResultSet rs)
A factory for TypeInfo objects. This method should always be used instead of directly constructing TypeInfo objects in order to give the DatabaseAdapter an opportunity to modify and/or correct the metadata obtained from the JDBC driver. The type information object is constructed from the current row of the given result set. The ResultSet object passed must have been obtained from a call to DatabaseMetaData.getTypeInfo().

The constructor only retrieves the values from the current row; the caller is required to advance to the next row with ResultSet.next()

Parameters:
rs - The result set returned from DatabaseMetaData.getTypeInfo().
Returns:
A TypeInfo object constructed from the current result set row, or null if the type indicated by this row should be excluded from use.

newColumnInfo

public ColumnInfo newColumnInfo(java.sql.ResultSet rs)
A factory for ColumnInfo objects. This method should always be used instead of directly constructing ColumnInfo objects in order to give the DatabaseAdapter an opportunity to modify and/or correct the metadata obtained from the JDBC driver. The column information object is constructed from the current row of the given result set. The ResultSet object passed must have been obtained from a call to DatabaseMetaData.getColumns().

The constructor only retrieves the values from the current row; the caller is required to advance to the next row with ResultSet.next()

Specified by:
newColumnInfo in interface RDBMSAdapter
Parameters:
rs - The result set returned from DatabaseMetaData.getColumns().
Returns:
The column info

newForeignKeyInfo

public ForeignKeyInfo newForeignKeyInfo(java.sql.ResultSet rs)
A factory for ForeignKeyInfo objects. This method should always be used instead of directly constructing ForeignKeyInfo objects in order to give the DatabaseAdapter an opportunity to modify and/or correct the metadata obtained from the JDBC driver. The column information object is constructed from the current row of the given result set. The ResultSet object passed must have been obtained from a call to DatabaseMetaData.getImportedKeys() or DatabaseMetaData.getExportedKeys().

The constructor only retrieves the values from the current row; the caller is required to advance to the next row with ResultSet.next()

Specified by:
newForeignKeyInfo in interface RDBMSAdapter
Parameters:
rs - The result set returned from DatabaseMetaData.get??portedKeys()
Returns:
The foreign key info

newExportedKeyInfo

public ExportedKeyInfo newExportedKeyInfo(java.sql.ResultSet rs)
A factory for ForeignKeyInfo objects. This method should always be used instead of directly constructing ForeignKeyInfo objects in order to give the DatabaseAdapter an opportunity to modify and/or correct the metadata obtained from the JDBC driver. The column information object is constructed from the current row of the given result set. The ResultSet object passed must have been obtained from a call to DatabaseMetaData.getExportedKeys().

The constructor only retrieves the values from the current row; the caller is required to advance to the next row with ResultSet.next()

Parameters:
rs - The result set returned from DatabaseMetaData.getExportedKeys()
Returns:
The ExportedKeyInfo

parseKeywordList

protected java.util.Set parseKeywordList(java.lang.String list)
Utility method to parse a list of keywords and split them out into words.

Parameters:
list - The comma-separated list of keywords.
Returns:
Set of keywords.

isSQLKeyword

public boolean isSQLKeyword(java.lang.String word)
Tests if a given string is a SQL key word.

The list of key words tested against is defined to contain all SQL/92 key words, plus any additional key words reported by the JDBC driver for this adapter via DatabaseMetaData.getSQLKeywords().

In general, use of a SQL key word as an identifier should be avoided. SQL/92 key words are divided into reserved and non-reserved words. If a reserved word is used as an identifier it must be quoted with double quotes. Strictly speaking, the same is not true of non-reserved words. However, as C.J. Date writes in A Guide To The SQL Standard :

The rule by which it is determined within the standard that one key word needs to be reserved while another need not is not clear to this writer. In practice, it is probably wise to treat all key words as reserved.

Specified by:
isSQLKeyword in interface RDBMSAdapter
Parameters:
word - The word to test.
Returns:
true if word is a SQL key word for this DBMS. The comparison is case-insensitive.
See Also:
SQLConstants

getTypeInfo

public TypeInfo getTypeInfo(int dataType)
                     throws org.jpox.store.exceptions.UnsupportedDataTypeException
Returns type information for the database type that best implements the given JDBC type. TODO The JDBC adapter often provides several database types and we have them present here and so could return them all as TypeInfo[].

Specified by:
getTypeInfo in interface RDBMSAdapter
Parameters:
dataType - JDBC type number of the data type.
Retu