Class DB2Platform
- java.lang.Object
-
- org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
-
- org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
- org.eclipse.persistence.platform.database.DatabasePlatform
-
- org.eclipse.persistence.platform.database.DB2Platform
-
- All Implemented Interfaces:
Serializable,Cloneable,org.eclipse.persistence.internal.core.databaseaccess.CorePlatform<org.eclipse.persistence.internal.helper.ConversionManager>,org.eclipse.persistence.internal.databaseaccess.Platform
- Direct Known Subclasses:
DB2MainframePlatform,DB2ZPlatform,DerbyPlatform
public class DB2Platform extends DatabasePlatform
Purpose: Provides DB2 specific behavior.
Responsibilities:
- Support for schema creation.
- Native SQL for byte[], Date, Time, & Timestamp.
- Support for table qualified names.
- Support for stored procedures.
- Support for temp tables.
- Support for casting.
- Support for database functions.
- Support for identity sequencing.
- Support for SEQUENCE sequencing.
- Since:
- TOPLink/Java 1.0
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.eclipse.persistence.platform.database.DatabasePlatform
DEFAULT_VARCHAR_SIZE
-
-
Constructor Summary
Constructors Constructor Description DB2Platform()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValueReadQuerybuildSelectQueryForIdentity()INTERNAL: Build the identity query for native sequencing.ValueReadQuerybuildSelectQueryForSequenceObject(String seqName, Integer size)INTERNAL: DB2 added SEQUENCE support as of (I believe) v8.booleandontBindUpdateAllQueryUsingTempTables()INTERNAL: DB2 has issues with binding with temp table queries.intgetMaxFieldNameSize()INTERNAL: returns the maximum number of characters that can be used in a field name on this platform.intgetMaxForeignKeyNameSize()INTERNAL: returns the maximum number of characters that can be used in a foreign key name on this platform.intgetMaxUniqueKeyNameSize()INTERNAL: returns the maximum number of characters that can be used in a unique key name on this platform.VectorgetNativeTableInfo(String table, String creator, org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Return the catalog information through using the native SQL catalog selects.StringgetProcedureAsString()INTERNAL: Used for stored procedure defs.StringgetProcedureBeginString()Used for stored procedure defs.StringgetProcedureCallHeader()INTERNAL: Used for sp calls.StringgetProcedureEndString()INTERNAL: Used for stored procedure defs.StringgetSelectForUpdateString()INTERNAL: Used for pessimistic locking in DB2.org.eclipse.persistence.internal.helper.DatabaseTablegetTempTableForTable(org.eclipse.persistence.internal.helper.DatabaseTable table)INTERNAL: DB2 temp table syntax.ValueReadQuerygetTimestampQuery()INTERNAL: This method returns the query to select the timestamp from the server for DB2.voidinitializeConnectionData(Connection connection)INTERNAL: Allow initialization from the connection.booleanisAlterSequenceObjectSupported()INTERNAL: DB2 added SEQUENCE support as of (I believe) v8.booleanisDB2()booleanisDynamicSQLRequiredForFunctions()INTERNAL DB2 has some issues with using parameters on certain functions and relations.booleanisNullAllowedInSelectClause()INTERNAL: DB2 does not allow NULL in select clause.HashtablemaximumNumericValues()INTERNAL: Builds a table of maximum numeric values keyed on java class.HashtableminimumNumericValues()INTERNAL: Builds a table of minimum numeric values keyed on java class.voidprintFieldIdentityClause(Writer writer)INTERNAL: Append the receiver's field 'identity' constraint clause to a writer.voidprintSQLSelectStatement(org.eclipse.persistence.internal.databaseaccess.DatabaseCall call, org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter printer, org.eclipse.persistence.internal.expressions.SQLSelectStatement statement)INTERNAL: Print the SQL representation of the statement on a stream, storing the fields in the DatabaseCall.booleanshouldIgnoreException(SQLException exception)INTERNAL: Allow for the platform to ignore exceptions.booleanshouldPrintForUpdateClause()booleanshouldPrintOutputTokenAtStart()INTERNAL: This is required in the construction of the stored procedures with output parameters.booleanshouldUseJDBCOuterJoinSyntax()INTERNAL: JDBC defines and outer join syntax, many drivers do not support this.booleansupportsGlobalTempTables()INTERNAL: DB2 supports temp tables.booleansupportsIdentity()INTERNAL: Indicates whether the platform supports identity.booleansupportsLockingQueriesWithMultipleTables()INTERNAL: DB2 does not seem to allow FOR UPDATE on queries with multiple tables.booleansupportsSequenceObjects()INTERNAL: DB2 added SEQUENCE support as of (I believe) v8.voidwriteParameterMarker(Writer writer, org.eclipse.persistence.internal.expressions.ParameterExpression parameter, org.eclipse.persistence.internal.sessions.AbstractRecord record, org.eclipse.persistence.internal.databaseaccess.DatabaseCall call)INTERNAL: DB2 requires casting on certain operations, such as the CONCAT function, and parameterized queries of the form, ":param = :param".-
Methods inherited from class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
addBatch, addStructConverter, allowsSizeInProcedureArguments, appendLiteralToCall, appendParameter, appendParameterInternal, autoCommit, beginTransaction, buildBatchCriteria, buildBatchCriteriaForComplexId, buildCallWithReturning, buildCreateIndex, buildCreateIndex, buildDropIndex, buildDropIndex, buildProcedureCallString, buildSequenceObjectAlterIncrementWriter, buildSequenceObjectCreationWriter, buildSequenceObjectDeletionWriter, canBatchWriteWithOptimisticLocking, canBuildCallWithReturning, commitTransaction, computeMaxRowsForSQL, convertToDatabaseType, copyInto, createArray, createArray, createStruct, createStruct, executeBatch, executeStoredProcedure, freeTemporaryObject, getAssignmentString, getBatchBeginString, getBatchDelimiterString, getBatchEndString, getBatchRowCountAssignString, getBatchRowCountDeclareString, getBatchRowCountReturnString, getBatchWritingMechanism, getCastSizeForVarcharParameter, getClassTypes, getConnection, getConnectionUserName, getConstraintDeletionString, getCreateDatabaseSchemaString, getCreateViewString, getCreationInOutputProcedureToken, getCreationOutputProcedureToken, getCursorCode, getCustomModifyValueForCall, getDefaultSequenceTableName, getDriverSupportsNVarChar, getDropCascadeString, getDropDatabaseSchemaString, getFieldTypeDefinition, getFieldTypes, getFunctionCallHeader, getIdentifierQuoteCharacter, getIndexNamePrefix, getInOutputProcedureToken, getInputProcedureToken, getJDBCOuterJoinString, getJDBCType, getJDBCType, getJDBCTypeForSetNull, getJdbcTypeName, getMaxBatchWritingSize, getMaxIndexNameSize, getNoWaitString, getObjectFromResultSet, getOutputProcedureToken, getPartitioningCallback, getPingSQL, getProcedureArgumentSetter, getProcedureArgumentString, getProcedureCallTail, getQualifiedName, getQualifiedSequenceTableName, getRefValue, getRefValue, getSelectForUpdateNoWaitString, getSelectForUpdateOfString, getSelectForUpdateWaitString, getSequenceCounterFieldName, getSequenceNameFieldName, getSequencePreallocationSize, getSequenceTableName, getStatementCacheSize, getStoredProcedureParameterPrefix, getStoredProcedureTerminationToken, getStringBindingSize, getStructConverters, getTableCreationSuffix, getTransactionIsolation, getTypeConverters, getUniqueConstraintDeletionString, getUseNationalCharacterVaryingTypeForString, getVPDClearIdentifierQuery, getVPDCreationFunctionString, getVPDCreationPolicyString, getVPDDeletionString, getVPDSetIdentifierQuery, hasPartitioningCallback, initialize, isCastRequired, isForUpdateCompatibleWithDistinct, isInformixOuterJoin, isJDBCExecuteCompliant, isLobCompatibleWithDistinct, isLockTimeoutException, isOutputAllowWithResultSet, isRowCountOutputParameterRequired, isXDBDocument, minimumTimeIncrement, prepareBatchStatement, printFieldNotNullClause, printFieldNullClause, printFieldTypeSize, printFieldUnique, printStoredFunctionReturnKeyWord, printValuelist, printValuelist, registerOutputParameter, requiresNamedPrimaryKeyConstraints, requiresProcedureBrackets, requiresProcedureCallBrackets, requiresProcedureCallOuputToken, requiresTableInIndexDropDDL, requiresTypeNameToRegisterOutputParameter, requiresUniqueConstraintCreationOnTableCreate, retrieveFirstPrimaryKeyOrOne, rollbackTransaction, setBatchWritingMechanism, setCastSizeForVarcharParameter, setCursorCode, setDriverName, setDriverSupportsNVarChar, setIsCastRequired, setMaxBatchWritingSize, setParameterValueInDatabaseCall, setPartitioningCallback, setPingSQL, setPrintInnerJoinInWhereClause, setPrintOuterJoinInWhereClause, setSequenceCounterFieldName, setSequenceNameFieldName, setSequenceTableName, setShouldBindAllParameters, setShouldBindLiterals, setShouldCacheAllStatements, setShouldCreateIndicesOnForeignKeys, setShouldForceFieldNamesToUpperCase, setShouldIgnoreCaseOnFieldComparisons, setShouldOptimizeDataConversion, setShouldTrimStrings, setShouldUseRownumFiltering, setStatementCacheSize, setStoredProcedureTerminationToken, setStringBindingSize, setSupportsAutoCommit, setTableCreationSuffix, setTransactionIsolation, setUseJDBCStoredProcedureSyntax, setUseNationalCharacterVaryingTypeForString, setUsesBatchWriting, setUsesByteArrayBinding, setUsesJDBCBatchWriting, setUsesNativeBatchWriting, setUsesNativeSQL, setUsesStreamsForBinding, setUsesStringBinding, shouldAlwaysUseTempStorageForModifyAll, shouldBindAllParameters, shouldBindLiterals, shouldCacheAllStatements, shouldCreateIndicesForPrimaryKeys, shouldCreateIndicesOnForeignKeys, shouldCreateIndicesOnUniqueKeys, shouldForceFieldNamesToUpperCase, shouldIgnoreCaseOnFieldComparisons, shouldOptimizeDataConversion, shouldPrintAliasForUpdate, shouldPrintConstraintNameAfter, shouldPrintFieldIdentityClause, shouldPrintInnerJoinInWhereClause, shouldPrintInOutputTokenBeforeType, shouldPrintInputTokenAtStart, shouldPrintLockingClauseAfterWhereClause, shouldPrintOuterJoinInWhereClause, shouldPrintOutputTokenBeforeType, shouldPrintStoredProcedureArgumentNameInCall, shouldPrintStoredProcedureVariablesAfterBeginString, shouldTrimStrings, shouldUseCustomModifyForCall, shouldUseGetSetNString, shouldUseRownumFiltering, supportsANSIInnerJoinSyntax, supportsAutoCommit, supportsAutoConversionToNumericForArithmeticOperations, supportsConnectionUserName, supportsCountDistinctWithMultipleFields, supportsDeleteOnCascade, supportsForeignKeyConstraints, supportsIndexes, supportsIndividualTableLocking, supportsLocalTempTables, supportsNestingOuterJoins, supportsOuterJoinsWithBrackets, supportsPrimaryKeyConstraint, supportsStoredFunctions, supportsTempTables, supportsUniqueColumns, supportsUniqueKeyConstraints, supportsVPD, usesBatchWriting, usesByteArrayBinding, usesJDBCBatchWriting, usesNativeBatchWriting, usesNativeSQL, usesSequenceTable, usesStreamsForBinding, usesStringBinding, wasFailureCommunicationBased, writeAddColumnClause, writeCleanUpTempTableSql, writeCreateTempTableSql, writeDeleteFromTargetTableUsingTempTableSql, writeInsertIntoTableSql, writeLOB, writeTableCreationSuffix, writeUpdateOriginalFromTempTableSql
-
Methods inherited from class org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
addSequence, addSequence, buildNativeCall, buildSelectQueryForIdentity, buildSelectQueryForSequenceObject, clone, convertObject, createConnectionCustomizer, getConversionManager, getDataTypesConvertedFrom, getDataTypesConvertedTo, getDefaultNativeSequenceToTable, getDefaultSequence, getDefaultSequenceToWrite, getEndDelimiter, getOperator, getPlatformOperators, getSelectSequenceQuery, getSequence, getSequences, getSequencesToWrite, getStartDelimiter, getTableQualifier, getTimestampFromServer, getUpdateSequenceQuery, hasDefaultSequence, initializeDefaultQueries, isAccess, isAttunity, isCloudscape, isDBase, isDerby, isFirebird, isH2, isHANA, isHSQL, isInformix, isMaxDB, isMySQL, isODBC, isOracle, isOracle9, isPervasive, isPointBase, isPostgreSQL, isSQLAnywhere, isSQLServer, isSybase, isSymfoware, isTimesTen, isTimesTen7, removeAllSequences, removeSequence, setConversionManager, setDefaultNativeSequenceToTable, setDefaultSequence, setEndDelimiter, setSelectSequenceNumberQuery, setSequencePreallocationSize, setSequences, setStartDelimiter, setTableQualifier, setTimestampQuery, setUpdateSequenceQuery, shouldNativeSequenceUseTransaction, shouldPrepare, shouldSelectDistinctIncludeOrderBy, shouldSelectIncludeOrderBy, supportsNativeSequenceNumbers, toString, usesPlatformDefaultSequence
-
-
-
-
Method Detail
-
initializeConnectionData
public void initializeConnectionData(Connection connection) throws SQLException
Description copied from class:org.eclipse.persistence.internal.databaseaccess.DatabasePlatformINTERNAL: Allow initialization from the connection.- Overrides:
initializeConnectionDatain classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform- Throws:
SQLException
-
getMaxFieldNameSize
public int getMaxFieldNameSize()
INTERNAL: returns the maximum number of characters that can be used in a field name on this platform.- Overrides:
getMaxFieldNameSizein classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
getMaxForeignKeyNameSize
public int getMaxForeignKeyNameSize()
INTERNAL: returns the maximum number of characters that can be used in a foreign key name on this platform.- Overrides:
getMaxForeignKeyNameSizein classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
getMaxUniqueKeyNameSize
public int getMaxUniqueKeyNameSize()
INTERNAL: returns the maximum number of characters that can be used in a unique key name on this platform.- Overrides:
getMaxUniqueKeyNameSizein classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
getNativeTableInfo
public Vector getNativeTableInfo(String table, String creator, org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Return the catalog information through using the native SQL catalog selects. This is required because many JDBC driver do not support meta-data. Wildcards can be passed as arguments. This is currently not used.
-
getProcedureCallHeader
public String getProcedureCallHeader()
INTERNAL: Used for sp calls.- Overrides:
getProcedureCallHeaderin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
getSelectForUpdateString
public String getSelectForUpdateString()
INTERNAL: Used for pessimistic locking in DB2. Without the "WITH RS" the lock is not held.- Overrides:
getSelectForUpdateStringin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
getProcedureEndString
public String getProcedureEndString()
INTERNAL: Used for stored procedure defs.- Overrides:
getProcedureEndStringin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
getProcedureBeginString
public String getProcedureBeginString()
Used for stored procedure defs.- Overrides:
getProcedureBeginStringin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
getProcedureAsString
public String getProcedureAsString()
INTERNAL: Used for stored procedure defs.- Overrides:
getProcedureAsStringin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
shouldPrintOutputTokenAtStart
public boolean shouldPrintOutputTokenAtStart()
INTERNAL: This is required in the construction of the stored procedures with output parameters.- Overrides:
shouldPrintOutputTokenAtStartin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
getTimestampQuery
public ValueReadQuery getTimestampQuery()
INTERNAL: This method returns the query to select the timestamp from the server for DB2.- Specified by:
getTimestampQueryin interfaceorg.eclipse.persistence.internal.databaseaccess.Platform- Overrides:
getTimestampQueryin classorg.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
-
isDB2
public boolean isDB2()
- Specified by:
isDB2in interfaceorg.eclipse.persistence.internal.databaseaccess.Platform- Overrides:
isDB2in classorg.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
-
maximumNumericValues
public Hashtable maximumNumericValues()
INTERNAL: Builds a table of maximum numeric values keyed on java class. This is used for type testing but might also be useful to end users attempting to sanitize values.NOTE: BigInteger & BigDecimal maximums are dependent upon their precision & Scale
- Overrides:
maximumNumericValuesin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
minimumNumericValues
public Hashtable minimumNumericValues()
INTERNAL: Builds a table of minimum numeric values keyed on java class. This is used for type testing but might also be useful to end users attempting to sanitize values.NOTE: BigInteger & BigDecimal minimums are dependent upon their precision & Scale
- Overrides:
minimumNumericValuesin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
shouldIgnoreException
public boolean shouldIgnoreException(SQLException exception)
INTERNAL: Allow for the platform to ignore exceptions. This is required for DB2 which throws no-data modified as an exception.- Overrides:
shouldIgnoreExceptionin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
shouldUseJDBCOuterJoinSyntax
public boolean shouldUseJDBCOuterJoinSyntax()
INTERNAL: JDBC defines and outer join syntax, many drivers do not support this. So we normally avoid it.- Overrides:
shouldUseJDBCOuterJoinSyntaxin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
buildSelectQueryForIdentity
public ValueReadQuery buildSelectQueryForIdentity()
INTERNAL: Build the identity query for native sequencing.- Overrides:
buildSelectQueryForIdentityin classorg.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
-
printFieldIdentityClause
public void printFieldIdentityClause(Writer writer) throws ValidationException
INTERNAL: Append the receiver's field 'identity' constraint clause to a writer. Used by table creation with sequencing.- Overrides:
printFieldIdentityClausein classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform- Throws:
ValidationException
-
supportsIdentity
public boolean supportsIdentity()
INTERNAL: Indicates whether the platform supports identity. DB2 does through AS IDENTITY field types. This is used by sequencing.- Overrides:
supportsIdentityin classorg.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
-
supportsGlobalTempTables
public boolean supportsGlobalTempTables()
INTERNAL: DB2 supports temp tables. This is used by UpdateAllQuerys.- Overrides:
supportsGlobalTempTablesin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
getTempTableForTable
public org.eclipse.persistence.internal.helper.DatabaseTable getTempTableForTable(org.eclipse.persistence.internal.helper.DatabaseTable table)
INTERNAL: DB2 temp table syntax. This is used by UpdateAllQuerys.- Overrides:
getTempTableForTablein classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform- Returns:
- DatabaseTable temorary table
-
dontBindUpdateAllQueryUsingTempTables
public boolean dontBindUpdateAllQueryUsingTempTables()
INTERNAL: DB2 has issues with binding with temp table queries. This is used by UpdateAllQuerys.- Overrides:
dontBindUpdateAllQueryUsingTempTablesin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
isNullAllowedInSelectClause
public boolean isNullAllowedInSelectClause()
INTERNAL: DB2 does not allow NULL in select clause. This is used by UpdateAllQuerys.- Overrides:
isNullAllowedInSelectClausein classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
isDynamicSQLRequiredForFunctions
public boolean isDynamicSQLRequiredForFunctions()
INTERNAL DB2 has some issues with using parameters on certain functions and relations. This allows statements to disable binding only in these cases. If users set casting on, then casting is used instead of dynamic SQL.- Overrides:
isDynamicSQLRequiredForFunctionsin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
writeParameterMarker
public void writeParameterMarker(Writer writer, org.eclipse.persistence.internal.expressions.ParameterExpression parameter, org.eclipse.persistence.internal.sessions.AbstractRecord record, org.eclipse.persistence.internal.databaseaccess.DatabaseCall call) throws IOException
INTERNAL: DB2 requires casting on certain operations, such as the CONCAT function, and parameterized queries of the form, ":param = :param". This method will write CAST operation to parameters if the type is known. This is not used by default, only if isCastRequired is set to true, by default dynamic SQL is used to avoid the issue in only the required cases.- Overrides:
writeParameterMarkerin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform- Throws:
IOException
-
supportsLockingQueriesWithMultipleTables
public boolean supportsLockingQueriesWithMultipleTables()
INTERNAL: DB2 does not seem to allow FOR UPDATE on queries with multiple tables. This is only used by testing to exclude these tests.- Overrides:
supportsLockingQueriesWithMultipleTablesin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
buildSelectQueryForSequenceObject
public ValueReadQuery buildSelectQueryForSequenceObject(String seqName, Integer size)
INTERNAL: DB2 added SEQUENCE support as of (I believe) v8.- Overrides:
buildSelectQueryForSequenceObjectin classorg.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
-
supportsSequenceObjects
public boolean supportsSequenceObjects()
INTERNAL: DB2 added SEQUENCE support as of (I believe) v8.- Overrides:
supportsSequenceObjectsin classorg.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
-
isAlterSequenceObjectSupported
public boolean isAlterSequenceObjectSupported()
INTERNAL: DB2 added SEQUENCE support as of (I believe) v8.- Overrides:
isAlterSequenceObjectSupportedin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
shouldPrintForUpdateClause
public boolean shouldPrintForUpdateClause()
- Overrides:
shouldPrintForUpdateClausein classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
printSQLSelectStatement
public void printSQLSelectStatement(org.eclipse.persistence.internal.databaseaccess.DatabaseCall call, org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter printer, org.eclipse.persistence.internal.expressions.SQLSelectStatement statement)INTERNAL: Print the SQL representation of the statement on a stream, storing the fields in the DatabaseCall. This implementation works MaxRows and FirstResult into the SQL using DB2's ROWNUMBER() OVER() to filter values if shouldUseRownumFiltering is true.- Overrides:
printSQLSelectStatementin classorg.eclipse.persistence.internal.databaseaccess.DatabasePlatform
-
-