com.triactive.jdo.store
Class DB2Adapter

java.lang.Object
  extended bycom.triactive.jdo.store.DatabaseAdapter
      extended bycom.triactive.jdo.store.DB2Adapter

class DB2Adapter
extends DatabaseAdapter

Provides methods for adapting SQL language elements to the DB2 database.

Author:
Mike Martin
See Also:
DatabaseAdapter

Field Summary
 
Fields inherited from class com.triactive.jdo.store.DatabaseAdapter
databaseMajorVersion, databaseMinorVersion, databaseProductName, databaseProductVersion, identifierQuoteString, keywords, maxColumnNameLength, maxConstraintNameLength, maxIndexNameLength, maxTableNameLength, storesLowerCaseIdentifiers, storesUpperCaseIdentifiers, typeMappings, typesByTypeNumber
 
Constructor Summary
protected DB2Adapter(java.sql.DatabaseMetaData metadata)
          Constructs a DB2 adapter based on the given JDBC metadata.
 
Method Summary
 java.lang.String getDropTableStatement(BaseTable table)
          Returns the appropriate SQL to drop the given table.
 java.lang.String getSchemaName(java.sql.Connection conn)
           
 int getUnlimitedLengthPrecisionValue(TypeInfo typeInfo)
          Returns the precision value to be used when creating string columns of "unlimited" length.
 java.lang.String getVendorID()
           
 NumericExpression lengthMethod(CharacterExpression str)
          Returns the appropriate SQL expression for the JDOQL String.length() method.
 ColumnInfo newColumnInfo(java.sql.ResultSet rs)
          A factory for ColumnInfo objects.
 TableExpression newTableExpression(QueryStatement qs, Table table, SQLIdentifier rangeVar)
          Returns a new TableExpression object appropriate for this DBMS.
 CharacterExpression substringMethod(CharacterExpression str, NumericExpression begin)
          Returns the appropriate SQL expression for the JDOQL String.substring(str,begin) method.
 CharacterExpression substringMethod(CharacterExpression str, NumericExpression begin, NumericExpression end)
          Returns the appropriate SQL expression for the JDOQL String.substring(str,begin,end) method.
 boolean supportsBooleanComparison()
           
 boolean supportsDeferredConstraints()
           
 boolean supportsNullsInCandidateKeys()
           
 
Methods inherited from class com.triactive.jdo.store.DatabaseAdapter
closeConnection, createIndexesBeforeForeignKeys, createTypeInfo, getAddCandidateKeyStatement, getAddForeignKeyStatement, getAddPrimaryKeyStatement, getConnection, getCreateIndexStatement, getCreateTableStatement, getDropViewStatement, getIdentifierQuoteString, getInstance, getMapping, getMapping, getMapping, getMappingClass, getMaxColumnNameLength, getMaxConstraintNameLength, getMaxIndexNameLength, getMaxTableNameLength, getSQLState, getTypeInfo, getTypeInfo, includeOrderByColumnsInSelect, isEmbeddedType, isSQLKeyword, newDataStoreException, newForeignKeyInfo, newQueryStatement, newQueryStatement, newTypeInfo, parseKeywordList, storesLowerCaseIdentifiers, storesUpperCaseIdentifiers, supportsAlterTableDropConstraint, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DB2Adapter

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

Parameters:
metadata - the database metadata.
Method Detail

getVendorID

public java.lang.String getVendorID()
Overrides:
getVendorID in class DatabaseAdapter

getSchemaName

public java.lang.String getSchemaName(java.sql.Connection conn)
                               throws java.sql.SQLException
Overrides:
getSchemaName in class DatabaseAdapter
Throws:
java.sql.SQLException

supportsBooleanComparison

public boolean supportsBooleanComparison()
Overrides:
supportsBooleanComparison in class DatabaseAdapter

supportsDeferredConstraints

public boolean supportsDeferredConstraints()
Overrides:
supportsDeferredConstraints in class DatabaseAdapter

supportsNullsInCandidateKeys

public boolean supportsNullsInCandidateKeys()
Overrides:
supportsNullsInCandidateKeys in class DatabaseAdapter

newColumnInfo

public ColumnInfo newColumnInfo(java.sql.ResultSet rs)
Description copied from class: DatabaseAdapter
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().

Overrides:
newColumnInfo in class DatabaseAdapter
Parameters:
rs - The result set returned from DatabaseMetaData.getColumns().

newTableExpression

public TableExpression newTableExpression(QueryStatement qs,
                                          Table table,
                                          SQLIdentifier rangeVar)
Description copied from class: DatabaseAdapter
Returns a new TableExpression object appropriate for this DBMS. This should be an instance of one of the three built-in styles of table expression: TableExprAsSubjoins is the default, which arguably produces the most readable SQL but doesn't work on all DBMS's. TableExprAsSubjoins should work anywhere, but may be less efficient.

Overrides:
newTableExpression in class DatabaseAdapter
Parameters:
qs - The query statement in which the table expression will be included.
table - The main table in the expression.
rangeVar - The SQL alias, or "range variable", to assign to the expression or to the main table.

getUnlimitedLengthPrecisionValue

public int getUnlimitedLengthPrecisionValue(TypeInfo typeInfo)
Description copied from class: DatabaseAdapter
Returns the precision value to be used when creating string columns of "unlimited" length. Usually, if this value is needed it is provided in the database metadata (TypeInfo.precision). However, for some types in some databases the value must be computed specially.

Overrides:
getUnlimitedLengthPrecisionValue in class DatabaseAdapter
Parameters:
typeInfo - the typeInfo object for which the precision value is needed.
Returns:
the precision value to be used when creating the column, or -1 if no value should be used.

getDropTableStatement

public java.lang.String getDropTableStatement(BaseTable table)
Description copied from class: DatabaseAdapter
Returns the appropriate SQL to drop the given table. It should return something like:

 DROP TABLE FOO CASCADE
 

Overrides:
getDropTableStatement in class DatabaseAdapter
Parameters:
table - The table to drop.
Returns:
The text of the SQL statement.

lengthMethod

public NumericExpression lengthMethod(CharacterExpression str)
Description copied from class: DatabaseAdapter
Returns the appropriate SQL expression for the JDOQL String.length() method. It should return something like:

 CHAR_LENGTH(str)
 

Overrides:
lengthMethod in class DatabaseAdapter
Parameters:
str - The argument to the length() method.
Returns:
The text of the SQL expression.

substringMethod

public CharacterExpression substringMethod(CharacterExpression str,
                                           NumericExpression begin)
Description copied from class: DatabaseAdapter
Returns the appropriate SQL expression for the JDOQL String.substring(str,begin) method. It should return something like:

 SUBSTRING(str FROM begin)
 
Note that the value of begin is base 0 (Java-style), while most SQL string functions use base 1.

Overrides:
substringMethod in class DatabaseAdapter
Parameters:
str - The first argument to the substring() method.
begin - The second argument to the substring() method.
Returns:
The text of the SQL expression.

substringMethod

public CharacterExpression substringMethod(CharacterExpression str,
                                           NumericExpression begin,
                                           NumericExpression end)
Description copied from class: DatabaseAdapter
Returns the appropriate SQL expression for the JDOQL String.substring(str,begin,end) method. It should return something like:

 SUBSTRING(str FROM begin FOR len)
 
Note that the value of begin is base 0 (Java-style), while most SQL string functions use base 1. Note also that an end position is given, while most SQL substring functions take a length.

Overrides:
substringMethod in class DatabaseAdapter
Parameters:
str - The first argument to the substring() method.
begin - The second argument to the substring() method.
end - The third argument to the substring() method.
Returns:
The text of the SQL expression.


Copyright © 2001 TriActive, Inc. All Rights Reserved.