Interface DataStoreHelper
-
- All Known Implementing Classes:
- CloudscapeDataStoreHelper, CloudscapeNetworkServerDataStoreHelper, ConnectJDBCDataStoreHelper, com.ibm.websphere.rsadapter.DataDirectDataStoreHelper, DB2390DataStoreHelper, DB2390LocalDataStoreHelper, DB2AS400DataStoreHelper, DB2DataStoreHelper, DB2UniversalDataStoreHelper, DerbyDataStoreHelper, DerbyNetworkServerDataStoreHelper, GenericDataStoreHelper, InformixDataStoreHelper, InformixJccDataStoreHelper, MicrosoftSQLServerDataStoreHelper, Oracle10gDataStoreHelper, Oracle11gDataStoreHelper, OracleDataStoreHelper, ProxyDSDataStoreHelper, Sybase11DataStoreHelper, SybaseDataStoreHelper
public interface DataStoreHelperThe
DataStoreHelperinterface allows users to plug in datastore-specific functionality required by the Relational Resource Adapter runtime. WebSphere provides aDataStoreHelperimplementation for each supported JDBC provider. In addition, WebSphere provides aGenericDataStoreHelperclass, which can be subclassed to add the functionality necessary for the Relational Resource Adapter to interoperate with SQL99 compliant JDBC drivers not officially supported by WebSphere.Custom
Note: This interface can not be referenced directly by user applications.DataStoreHelperimplementations are required to inherit from theGenericDataStoreHelperclass, as WebSphere does not support direct implementation of theDataStoreHelperinterface. New releases of WebSphere might involve changes to theDataStoreHelperinterface. These changes are picked up automatically by custom helpers only if they inherit fromGenericDataStoreHelper. Custom helpers that do not inherit fromGenericDataStoreHelpermight encounter compile problems and runtime errors.- Since:
- WAS 5.0
- Version:
- 1.31.10.2
- See Also:
GenericDataStoreHelper
-
-
Field Summary
Fields Modifier and Type Field and Description static intCLOUDSCAPE_HELPERDeprecated.DataStoreHelper.DERBY_HELPER should be used instead.static intCLOUDSCAPE_NETWORK_SERVER_HELPERDeprecated.DataStoreHelper.DERBY_NETWORK_SERVER_HELPER should be used instead.static intCONNECTJDBC_HELPERThis constant is used to identify the type ofDataStoreHelper.static intCUSTOM_HELPERDeprecated.static intDATADIRECT_HELPERDeprecated.Please use CONNECTJDBC_HELPER or MSSQL_HELPER instead.static intDB2_390_HELPERThis constant is used to identify the type ofDataStoreHelper.static intDB2_390_LOCAL_HELPERThis constant is used to identify the type ofDataStoreHelper.static intDB2_400_HELPERThis constant is used to identify the type ofDataStoreHelper.static intDB2_HELPERThis constant is used to identify the type ofDataStoreHelper.static intDB2_UNIVERSAL_HELPERThis constant is used to identify the type ofDataStoreHelper.static intDERBY_HELPERThis constant is used to identify the type ofDataStoreHelper.static intDERBY_NETWORK_SERVER_HELPERThis constant is used to identify the type ofDataStoreHelper.static java.lang.StringFIRST_TIME_CALLEDThis string constant is to be used as a property name in the properties passed on theDataStoreHelper.doConnectionSetupPerTransaction().static intGENERIC_HELPERThis constant is used to identify the type ofDataStoreHelper.static intINFORMIX_HELPERThis constant is used to identify the type ofDataStoreHelper.static intINFORMIX_JCC_HELPERThis constant is used to identify the type ofDataStoreHelper.static intMSSQL_HELPERThis constant is used to identify the type ofDataStoreHelperas the Microsoft SQL Server JDBC Driver.static intORACLE_10G_HELPERDeprecated.This constant will be removed in a later release. Please use ORACLE_11G_HELPER instead.static intORACLE_11G_HELPERThis constant is used to identify the type ofDataStoreHelper.static intORACLE_HELPERDeprecated.This constant will be removed in a later release. Please use ORACLE_11G_HELPER instead.static java.lang.StringPOTENTIAL_DEADLOCKA deadlock is possible.static java.lang.StringPOTENTIAL_LOST_UPDATEA lost update is possible.static intPROXY_DS_HELPERThis constant is used to identify the type ofDataStoreHelper.static intSEQUELINK_HELPERDeprecated.Please use CONNECTJDBC_HELPER or MSSQL_HELPER instead.static java.lang.StringSUBJECTProperty key that specifies thejavax.security.auth.SubjectfordoConnectionSetupPerGetConnection.static intSYBASE_HELPERThis constant is used to identify the type ofDataStoreHelper.static intSYBASE11_HELPERThis constant is used to identify the type ofDataStoreHelper.static java.lang.StringTX_REPEATABLE_READ_FORUPDATEThis string is needed for the extended-for-update support for some databases (e.g.static java.lang.StringTX_SERIALIZABLE_FORUPDATEThis string is needed for the extended-for-update support for some databases (e.g.static intUNDEFINED_HELPERThis constant is used to identify the type ofDataStoreHelper.static intUNDEFINED_ISOLATOIN_LEVELstatic variable holder for undefined isolation levelstatic java.lang.StringUPDATE_ON_READONLYAn update is being attempted, but a read-only AccessIntent was specified.
-
Method Summary
Methods Modifier and Type Method and Description shortcalcPartitionNumber(java.lang.String fullTableName, java.util.Properties propPartKeys)This method allows you to calculate the partition number based on the input table name and partition key properties.booleandoConnectionCleanup(java.sql.Connection conn)This method is used to clean up a connection before it is returned to the connection pool for later reuse.booleandoConnectionCleanupPerCloseConnection(java.sql.Connection conn, boolean isCMP, java.lang.Object props)This method is invoked by WebSphere Application Server runtime immediately after a connection handle is closed by the application or implicitly by WebSphere Application Server runtime.booleandoConnectionCleanupWithValidCheck(java.sql.Connection conn)voiddoConnectionSetup(java.sql.Connection conn)This method configures a connection before first use.booleandoConnectionSetupPerGetConnection(java.sql.Connection conn, boolean isCMP, java.lang.Object props)This method is invoked by WebSphere Application Server runtime before a connection handle is provided to the application.voiddoConnectionSetupPerTransaction(javax.security.auth.Subject sub, java.lang.String user, java.sql.Connection conn, boolean reauthRequired, java.lang.Object properties)This method is invoked by WebSphere runtime each time a connection comes out of the connection pool and only before transactions begin on that connection.voiddoStatementCleanup(java.sql.PreparedStatement stmt)This method cleans up a statement before the statement is placed in the statement cache.intgetIsolationLevel(AccessIntent intent)This method determines the transaction isolation level based on the specifiedAccessIntent.intgetLockType(AccessIntent intent)This method returns a lock type constant based on the update hint value of the specified AccessIntent.DataStoreHelperMetaDatagetMetaData()This method returns theDataStoreHelperMetaDataobject associated with thisDataStoreHelper.java.lang.StringgetPasswordForUseWithTrustedContextWithAuthentication(java.lang.String identityname, java.lang.String realm)The application server invokes this method at run time to get the password that the application server will use to establish a trusted connection using the DB2 TrustedContext "with authentication" option or when the application server switches a trusted connection to another identity, and the "with authentication" option is enabled.java.io.PrintWritergetPrintWriter()This method is used to obtain thejava.io.PrintWriterto use for logging when database logging is enabled (for example:WAS.database=all=enabled).intgetResultSetConcurrency(AccessIntent intent)This method determines the result set concurrency based on the specifiedAccessIntent.intgetResultSetType(AccessIntent intent)This method determines the result set type based on the specifiedAccessIntent.java.lang.StringgetXAExceptionContents(javax.transaction.xa.XAException xae)This method provides a plug-in point for providing meaningful logging information for anXAException.java.lang.StringhasLostUpdateOrDeadLockOccurred(int isoLevel, boolean loadedForUpdate)This method is invoked when storing a CMP EntityBean if pessimistic concurrency control is activated.booleanisBatchUpdateSupportedWithAccessIntent(AccessIntent accessIntent)This method is used to determine if CMP Entity Beans can support batch updates with the given AccessIntent.booleanisConnectionError(java.sql.SQLException ex)This method determines whether aSQLExceptionindicates a fatal connection error based on the exception map for this data store helper.booleanisDuplicateKey(java.sql.SQLException sqlX)The application server invokes this method to determine whether or not the specified error indicates a duplicate key violation.booleanisTransientConnectionError(java.sql.SQLException ex)This method determines whether aSQLExceptionindicates a transient connection error.java.sql.SQLExceptionmapException(java.sql.SQLException e)The application server uses this API to replace java.sql.SQLExceptions with the exceptions defined in the map if the data source's error detection model is configured to exception mapping.intmodifyXAFlag(int xaflag)This method is used only when thetransactionBranchesLooselyCoupledcustom DataSource property is set to true.voidsetUserDefinedMap(java.util.Map newmap)This method configures a user-definedSQLExceptionmap that supersedes the defaultSQLExceptionmappings for theDataStoreHelper.
-
-
-
Field Detail
-
UNDEFINED_ISOLATOIN_LEVEL
static final int UNDEFINED_ISOLATOIN_LEVEL
static variable holder for undefined isolation level- See Also:
- Constant Field Values
-
POTENTIAL_LOST_UPDATE
static final java.lang.String POTENTIAL_LOST_UPDATE
A lost update is possible. A transaction is attempting an update to a CMP entity bean. If another concurrently executing transaction is updating the same CMP entity bean, the updates of one transaction might overlay the updates of the other transaction.- See Also:
- Constant Field Values
-
UPDATE_ON_READONLY
static final java.lang.String UPDATE_ON_READONLY
An update is being attempted, but a read-only AccessIntent was specified. A transaction is attempting an update to a CMP entity bean and the bean was deployed using read-only AccessIntent.- See Also:
- Constant Field Values
-
POTENTIAL_DEADLOCK
static final java.lang.String POTENTIAL_DEADLOCK
A deadlock is possible. A transaction is attempting an update to a CMP entity bean. The bean is deployed using read-only AccessIntent and either JDBC repeatable read or JDBC serializable isolation level. If another transaction is storing the same CMP entity bean, a database deadlock can occur as a result of promotion of a read/share lock to a write/exclusive lock.- See Also:
- Constant Field Values
-
FIRST_TIME_CALLED
static final java.lang.String FIRST_TIME_CALLED
This string constant is to be used as a property name in the properties passed on theDataStoreHelper.doConnectionSetupPerTransaction().
The property is used to specify if thedoConnectionSetupPerTransaction()is called for the first time, on the underlying physical connection, by WebSphere runtime.- See Also:
- Constant Field Values
-
SUBJECT
static final java.lang.String SUBJECT
Property key that specifies thejavax.security.auth.SubjectfordoConnectionSetupPerGetConnection.- See Also:
- Constant Field Values
-
TX_REPEATABLE_READ_FORUPDATE
static final java.lang.String TX_REPEATABLE_READ_FORUPDATE
This string is needed for the extended-for-update support for some databases (e.g. DB2 390)- See Also:
- Constant Field Values
-
TX_SERIALIZABLE_FORUPDATE
static final java.lang.String TX_SERIALIZABLE_FORUPDATE
This string is needed for the extended-for-update support for some databases (e.g. DB2 390)- See Also:
- Constant Field Values
-
CLOUDSCAPE_HELPER
static final int CLOUDSCAPE_HELPER
Deprecated. DataStoreHelper.DERBY_HELPER should be used instead.This constant is used to identify theCloudscapeDataStoreHelpertype. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.CLOUDSCAPE_HELPER)is configured when constructing theCloudscapeDataStoreHelper.- See Also:
- Constant Field Values
-
CLOUDSCAPE_NETWORK_SERVER_HELPER
static final int CLOUDSCAPE_NETWORK_SERVER_HELPER
Deprecated. DataStoreHelper.DERBY_NETWORK_SERVER_HELPER should be used instead.This constant is used to identify theCloudscapeNetworkServerDataStoreHelpertype. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.CLOUDSCAPE_NETWORK_SERVER_HELPER)is configured when constructing theCloudscapeNetworkServerDataStoreHelper.- See Also:
- Constant Field Values
-
CUSTOM_HELPER
static final int CUSTOM_HELPER
Deprecated.This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
ORACLE_HELPER
static final int ORACLE_HELPER
Deprecated. This constant will be removed in a later release. Please use ORACLE_11G_HELPER instead.These constants are kept only for compatibility reasons.- See Also:
- Constant Field Values
-
ORACLE_10G_HELPER
static final int ORACLE_10G_HELPER
Deprecated. This constant will be removed in a later release. Please use ORACLE_11G_HELPER instead.These constants are kept only for compatibility reasons.- See Also:
- Constant Field Values
-
UNDEFINED_HELPER
static final int UNDEFINED_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
DB2_HELPER
static final int DB2_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
DB2_400_HELPER
static final int DB2_400_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
DB2_390_HELPER
static final int DB2_390_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
DB2_UNIVERSAL_HELPER
static final int DB2_UNIVERSAL_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
GENERIC_HELPER
static final int GENERIC_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
CONNECTJDBC_HELPER
static final int CONNECTJDBC_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
SYBASE_HELPER
static final int SYBASE_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
SYBASE11_HELPER
static final int SYBASE11_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
INFORMIX_HELPER
static final int INFORMIX_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
DB2_390_LOCAL_HELPER
static final int DB2_390_LOCAL_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
PROXY_DS_HELPER
static final int PROXY_DS_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
DERBY_NETWORK_SERVER_HELPER
static final int DERBY_NETWORK_SERVER_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
DERBY_HELPER
static final int DERBY_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
INFORMIX_JCC_HELPER
static final int INFORMIX_JCC_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
ORACLE_11G_HELPER
static final int ORACLE_11G_HELPER
This constant is used to identify the type ofDataStoreHelper. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.DB2_HELPER)is configured when constructing theDB2DataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
DATADIRECT_HELPER
static final int DATADIRECT_HELPER
Deprecated. Please use CONNECTJDBC_HELPER or MSSQL_HELPER instead.This constant is kept only for compatibility reasons.- See Also:
- Constant Field Values
-
SEQUELINK_HELPER
static final int SEQUELINK_HELPER
Deprecated. Please use CONNECTJDBC_HELPER or MSSQL_HELPER instead.This constant is kept only for compatibility reasons.- See Also:
- Constant Field Values
-
MSSQL_HELPER
static final int MSSQL_HELPER
This constant is used to identify the type ofDataStoreHelperas the Microsoft SQL Server JDBC Driver. TheDataStoreHelperMetaDataHelperType property is configured to theDataStoreHelpertype constant of the correspondingDataStoreHelpersubclass. For example,setHelperType(DataStoreHelper.MSSQL_HELPER)is configured when constructing theMicrosoftSQLServerDataStoreHelper. When you define a customDataStoreHelper, the HelperType will be set automatically by theDataStoreHelperimplementation class which you extend.- See Also:
- Constant Field Values
-
-
Method Detail
-
isDuplicateKey
boolean isDuplicateKey(java.sql.SQLException sqlX)
The application server invokes this method to determine whether or not the specified error indicates a duplicate key violation. The method is invoked regardless of the data source's error detection model.
- Parameters:
sqlX- the error.- Returns:
- true if the error indicates a duplicate key violation, otherwise false.
-
mapException
java.sql.SQLException mapException(java.sql.SQLException e)
The application server uses this API to replace java.sql.SQLExceptions with the exceptions defined in the map if the data source's error detection model is configured to exception mapping. If configured to exception checking, then the application server consults the map to help determine the cause of the error, but does not replace the exception.
This method maps the specifiedSQLExceptionto a correspondingcom.ibm.websphere.ce.cm.PortableSQLExceptionsubclass. If no correspondingcom.ibm.websphere.ce.cm.PortableSQLExceptionsubclass is found, theSQLExceptionis returned unchanged.- Parameters:
e- aSQLException.- Returns:
- a
com.ibm.websphere.ce.cm.PortableSQLExceptionsubclass corresponding to the specifiedSQLException, or the unchangedSQLExceptionif no match is found.
-
hasLostUpdateOrDeadLockOccurred
java.lang.String hasLostUpdateOrDeadLockOccurred(int isoLevel, boolean loadedForUpdate)This method is invoked when storing a CMP EntityBean if pessimistic concurrency control is activated. This method determines whether a potential lost update or deadlock scenario has occurred. If so, this method returns an appropriate message ID. This information is passed on to the bean provider as notification that code changes are needed to avoid potential problems.pre-conditions
- pessimistic concurrency control is being used
- getAutoCommit() on the connection returns false
- Parameters:
isoLevel- the transaction isolation level used.loadedForUpdate-trueif the CMP EntityBean was loaded for update (eg. FOR UPDATE keywords used on SELECT), otherwise false.- Returns:
- One of the following
-
getIsolationLevel
int getIsolationLevel(AccessIntent intent) throws javax.resource.ResourceException
This method determines the transaction isolation level based on the specifiedAccessIntent. If theAccessIntentparameter is null, a default value that is appropriate for the database backend should be returned.WebSphere's default transaction isolation levels are:
- For Oracle and unsupported databases -
java.sql.Connection.TRANSACTION_READ_COMMITTED - For all other supported databases -
java.sql.Connection.TRANSACTION_REPEATABLE_READ
- Parameters:
intent- AnAccessIntent- Returns:
- A transaction isolation level appropriate for the specified
AccessIntent. - Throws:
javax.resource.ResourceException- If a transaction isolation level cannot be determined from theAccessIntent.
- For Oracle and unsupported databases -
-
getResultSetType
int getResultSetType(AccessIntent intent) throws javax.resource.ResourceException
This method determines the result set type based on the specifiedAccessIntent. If theAccessIntentparameter is null, the a default value ofjava.sql.ResultSet.FETCH_FORWARDmust be returned. Currently allDataStoreHelpersubclasses provided by WebSphere returnjava.sql.ResultSet.FETCH_FORWARD.- Parameters:
intent- AnAccessIntent.- Returns:
- A result set type constant defined on
java.sql.ResultSet. - Throws:
javax.resource.ResourceException- If a result set type cannot be determined from theAccessIntent.
-
getResultSetConcurrency
int getResultSetConcurrency(AccessIntent intent) throws javax.resource.ResourceException
This method determines the result set concurrency based on the specifiedAccessIntent. If theAccessIntentparameter is null, a default value ofjava.sql.ResultSet.CONCUR_READ_ONLYmust be returned.- Parameters:
intent- AnAccessIntent.- Returns:
- A result set concurrency constant defined on
java.sql.ResultSet. - Throws:
javax.resource.ResourceException- If a result set concurrency cannot be determined from theAccessIntent.
-
doConnectionSetup
void doConnectionSetup(java.sql.Connection conn) throws java.sql.SQLExceptionThis method configures a connection before first use. This method is invoked only when a new connection to the database is created. It is not invoked when connections are reused from the connection pool.
One example of where this method is useful is the following:
- The Informix JDBC driver requires that the
LOCK MODEis configured according to theinformixLockModeWaitproperty.
The following actions are prohibited in this method:
- Changing any standard connection properties found on the
java.sql.ConnectionAPI. This includes TransactionIsolationLevel, AutoCommit, Catalog, ReadOnly, TypeMap, and Holdability. - Closing the connection.
- Parameters:
conn- the connection to set up.- Throws:
java.sql.SQLException- if connection setup cannot be completed successfully.
- The Informix JDBC driver requires that the
-
isConnectionError
boolean isConnectionError(java.sql.SQLException ex)
This method determines whether aSQLExceptionindicates a fatal connection error based on the exception map for this data store helper.The application server uses this API to detect fatal connection errors.
- Parameters:
ex- theSQLExceptionto check.- Returns:
- true if the exception indicates a fatal connection error, otherwise false.
-
doConnectionCleanup
boolean doConnectionCleanup(java.sql.Connection conn) throws java.sql.SQLExceptionThis method is used to clean up a connection before it is returned to the connection pool for later reuse. WebSphere automatically resets all standard connection properties (fields for which getters and setters are defined on
java.sql.Connection). This method can be used to reset other properties proprietary to a specific JDBC driver/database, preparing the connection for reuse.A
DataStoreHelperis permitted to use the provided connection to create and execute statements for the purpose of cleaning up the connection. Any statements created within thedoConnectionCleanupmethod must be explicitly closed within thedoConnectionCleanupmethod. ThedoConnectionCleanupmethod must never close the connection being cleaned up.If any standard connection properties are modified in this method, a value of true must be returned, indicating to WebSphere that at least one standard connection property was modified. A value of false should be returned only if no standard connection properties were modified.
- Parameters:
conn- the connection to attempt to cleanup.- Returns:
- true if any standard connection property was modified, otherwise false.
- Throws:
java.sql.SQLException- If an error occurs while cleaning up the connection.
-
doConnectionCleanupWithValidCheck
boolean doConnectionCleanupWithValidCheck(java.sql.Connection conn) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
doStatementCleanup
void doStatementCleanup(java.sql.PreparedStatement stmt) throws java.sql.SQLExceptionThis method cleans up a statement before the statement is placed in the statement cache. This method is called only for statements being cached. It is called when at least one of the following statement properties has changed,
- cursorName
- fetchDirection
- maxFieldSize
- maxRows
- queryTimeout
The GenericDataStoreHelper implementation for this method resets all five of the properties listed above.
The following operations do not need to be included in the statement cleanup because they are automatically performed by WebSphere when caching statements:
setFetchSize(0)clearParameters()clearWarnings()
A helper class implementing this method can choose to do additional cleanup for the statement. However, this should never include closing the statement because the statement is intended to be cached.
- Parameters:
stmt- the PreparedStatement.- Throws:
java.sql.SQLException- if an error occurs cleaning up the statement.
-
getMetaData
DataStoreHelperMetaData getMetaData()
This method returns theDataStoreHelperMetaDataobject associated with thisDataStoreHelper.- Returns:
DataStoreHelperMetaData
-
getLockType
int getLockType(AccessIntent intent)
This method returns a lock type constant based on the update hint value of the specified AccessIntent. The lock type is used by the persistence manager to determine which locking hints are used on aSELECTstatement.- Parameters:
intent- AnAccessIntent- Returns:
- the lock type constant. Valid values are defined in
com.ibm.websphere.rsadaper.WSInteractionSpec:LOCKTYPE_SELECTLOCKTYPE_SELECT_FOR_UPDATELOCKTYPE_SELECT_FOR_UPDATE_WITH_RSLOCKTYPE_SELECT_FOR_UPDATE_WITH_RR
-
setUserDefinedMap
void setUserDefinedMap(java.util.Map newmap)
This method configures a user-defined
SQLExceptionmap that supersedes the defaultSQLExceptionmappings for theDataStoreHelper. TheDataStoreHelperimplementations that are provided by the application server useSQLExceptionmaps to detect connection errors that can end connections, as well as other specific types of errors. A customDataStoreHelpercan alter the default mappings by invoking this method. Do not invoke this method from a customDataStoreHelperif you also configure theuserDefinedErrorMapdata source custom property. When you configure theuserDefinedErrorMapcustom data source property, the application server invokes this method to overlay the default error mappings with the error mappings that are specified in the custom property. Do not invoke this method directly from application code.Example usage of the
setUserDefinedMapmethod:public MyCustomDataStoreHelper() { ... java.util.HashMap MyErrorMap = new java.util.HashMap(2); myErrorMap.put(new Integer(-801), MyDuplicateKeyException.class); myErrorMap.put(new Integer(-1015), MyStaleConnectionException.class); setUserDefinedMap(myErrorMap); ... }User-defined exception mapping takes priority over all other exception mapping done by a
DataStoreHelper. This differs from the WAS 4.0 DataSource model where mapping by Error Code always takes precedence over mapping by SQL State.For example, assume the following exception mappings are defined:
User-defined mappings: SQL State S1000 --> UserDefinedException Default mappings: Error Code 23505 --> DuplicateKeyException SQL State S1000 --> StaleConnectionException
Given the above mappings, if a
SQLExceptionis received with SQL State S1000 and Error Code 23505, the WebSphereDataStoreHelperimplementations map the exception toUserDefinedException, whereas the WAS 4.0 DataSource map the exception toDuplicateKeyException.Additionally, mapping done by the WebSphere
DataStoreHelpers does not include mapping by chained exceptions when no match is found for the original exception.- Parameters:
newmap- a mapping ofSQLExceptionSQL States and Error Codes tocom.ibm.websphere.ce.cm.PortableSQLExceptionsubclasses. The key for the Map must be aString(representing the SQL State) or anInteger(representing the Error Code). The value for the Map must be a subclass ofcom.ibm.websphere.ce.cm.PortableSQLException. User-defined subclasses are permitted, but are required to declare a public constructor accepting aSQLExceptionas the single parameter.Void.classmay also be used for the value, in which case any existing mapping for the specified SQL State or Error Code is removed.
-
calcPartitionNumber
short calcPartitionNumber(java.lang.String fullTableName, java.util.Properties propPartKeys) throws javax.resource.ResourceExceptionThis method allows you to calculate the partition number based on the input table name and partition key properties. This method is reserved for future use and is not currently called by WebSphere.- Parameters:
fullTableName- - the fully qualified table name.propPartKeys- - the partition key properties- Returns:
- a partition number.
- Throws:
javax.resource.ResourceException- any exception that occurs during the calculation of a partition key will result in a ResourceException
-
getPrintWriter
java.io.PrintWriter getPrintWriter()
This method is used to obtain thejava.io.PrintWriterto use for logging when database logging is enabled (for example:WAS.database=all=enabled). By default, null is returned and ajava.io.PrintWriterinstance created by WebSphere is used. You can override this method to return a differentjava.io.PrintWriterinstance instead of the default.- Returns:
java.io.PrintWriter.- Since:
- WAS 5.0.1
-
getXAExceptionContents
java.lang.String getXAExceptionContents(javax.transaction.xa.XAException xae)
This method provides a plug-in point for providing meaningful logging information for anXAException. The information can include details of the original exception that caused theXAException, if applicable. WebSphere uses this method to obtain trace information forXAExceptions to include in WebSphere trace.- Parameters:
xae- theXAException.- Returns:
- detailed information about the
XAException, for inclusion in a WebSphere trace. - Since:
- WAS 5.0.2
-
modifyXAFlag
int modifyXAFlag(int xaflag)
This method is used only when the
transactionBranchesLooselyCoupledcustom DataSource property is set to true. This method modifies the given XA start flag. Some databases, such as Oracle, require a proprietary flag, such asOracleXAResource.ORATRANSLOOSE.Among the
DataStoreHelpersubclasses provided by WebSphere, this method is a no-op for every backend except for Oracle.- Parameters:
xaflag- The XA start flag to modify.- Returns:
- The modified XA start flag.
- Since:
- WAS 5.0.1
-
isBatchUpdateSupportedWithAccessIntent
boolean isBatchUpdateSupportedWithAccessIntent(AccessIntent accessIntent)
This method is used to determine if CMP Entity Beans can support batch updates with the given AccessIntent. There are some AccessIntents (for example, WebSphere Optimistic Concurrency Control intent) for which some databases are not always capable of determining the number of updated rows. This prevents CMP Entity Beans from being able to support batch updates. In such cases, this method must return false.- Parameters:
accessIntent- AccessIntent- Returns:
- boolean true if batching is allowed with the given AccessIntent, otherwise false.
- Since:
- WAS 5.0.2
-
doConnectionSetupPerTransaction
void doConnectionSetupPerTransaction(javax.security.auth.Subject sub, java.lang.String user, java.sql.Connection conn, boolean reauthRequired, java.lang.Object properties) throws java.sql.SQLExceptionThis method is invoked by WebSphere runtime each time a connection comes out of the connection pool and only before transactions begin on that connection. This method is different from thedoConnectionSetup()method which is only called when a physical connection is first created.
Implementation of this method is required if the "reauthentication" datasource custom property is set to true or if "enable reauthentication checkbox" is checked. Failure to do so might result in unpredictable behavior.
This method is not only limited to user reauthentication; users can also take advantage of this method in other situations. For example:
- altering the identity for audit purposes
- altering the target schema
java.sql.Connectionproperties.
Note also that users might need to implement the doConnectionCleanup() method to reset thejava.sql.Connectionto the original state prior to callingdoConnectionSetupPerTransaction
Note also that WebSphere runtime will passjava.util.Propertiesobject which contains a propertyDataStoreHelper.FIRST_TIME_CALLED. TheDataStoreHelper.FIRST_TIME_CALLEDis set to true when thedoConnectionSetupPerTransactionis called by WebSphere runtime for the first time for any WebSphere connection. TheDataStoreHelper.FIRST_TIME_CALLEDis set to false thereafter.- Parameters:
sub- javax.security.auth.Subject for the newly requested connection. This value is null unlessres-authis set to container.user- java.lang.String user name of the newly requested connection. This value is specified only if the subject is null.conn- java.sql.ConnectionreauthRequired- boolean that indicates whether reauthentication is required on the passed connection to get the connection in sync with the subject or user name:- FALSE: connection is in sync with the passed subject or user name.
- TRUE: conneciton is not in sync with the passed subject or user name. In this case, users are required to provide reauthentication implementation for the connection.
properties- java.lang.Object WebSphere runtime passesjava.util.Propertieswhen calling this method- Throws:
java.sql.SQLException- if connection throws an exception.
-
doConnectionSetupPerGetConnection
boolean doConnectionSetupPerGetConnection(java.sql.Connection conn, boolean isCMP, java.lang.Object props) throws java.sql.SQLExceptionThis method is invoked by WebSphere Application Server runtime before a connection handle is provided to the application. This method is called by WebSphere Application Server runtime when the connection handle provided is the only handle for the associated ManagedConnection. Thus, if connection sharing occurs, this method will not be called when additional connection handles are provided to the application for the same ManagedConnection. If connection handle usage follows a get/use/close pattern, such that the ManagedConnection has only 1 active connection handle outstanding at a time, then this method will be invoked for each getConnection call made by the application.
This method may be overridden to provide code to set up a connection before its use by the application. This is particularly useful when dealing with CMP, where applications don't have direct access to connections.
Note that The get/use/close pattern must be used by the application if this method is overridden.- Parameters:
conn- java.sql.Connection the underlying database physical connectionisCMP- boolean: specifies if the connection is used for a CMP request or another type of request.props- Map<String,Object> containing additional properties. The keyDataStoreHelper.SUBJECTmaps to thejavax.security.auth.Subjectif a Subject is available.- Returns:
- boolean false indicates no connection setup is performed by this method, true otherwise. Default is false as its a no-op.
- Throws:
java.sql.SQLException
-
doConnectionCleanupPerCloseConnection
boolean doConnectionCleanupPerCloseConnection(java.sql.Connection conn, boolean isCMP, java.lang.Object props) throws java.sql.SQLExceptionThis method is invoked by WebSphere Application Server runtime immediately after a connection handle is closed by the application or implicitly by WebSphere Application Server runtime. If you override thedoConnectionSetupPerGetConnectionmethod to perform connection setup, then you must override this method to undo all connection setup done in thedoConnectionSetupPerGetConnectionmethod.
This method is called by WebSphere Application Server runtime when the connection handle closed is the last active handle for the associated ManagedConnection. Thus, if connection sharing occurs, this method will not be called when additional connection handles are active for the same ManagedConnection. If connection handle usage follows a get/use/close pattern, such that the ManagedConnection has only 1 connection handle outstanding at a time, then this method will be invoked for each Connection.close call made by the application. If the end of a transaction (commit or rollback) occurs before Connection.close is called, then the connection handle is dissociated from the ManagedConnection and this method is not invoked.
Note that the get/use/close pattern must be used by the application when this method is overridden.- Parameters:
conn- java.sql.Connection the underlying database physical connectionisCMP- boolean: specifies if the connection is used for a CMP request or another type of request.props- java.lang.Object this is not used and is a place holder for future changes.- Returns:
- boolean false indicates no connection cleanup is performed by this method, true otherwise. Default is false as its a no-op.
- Throws:
java.sql.SQLException
-
getPasswordForUseWithTrustedContextWithAuthentication
java.lang.String getPasswordForUseWithTrustedContextWithAuthentication(java.lang.String identityname, java.lang.String realm) throws java.sql.SQLExceptionThe application server invokes this method at run time to get the password that the application server will use to establish a trusted connection using the DB2 TrustedContext "with authentication" option or when the application server switches a trusted connection to another identity, and the "with authentication" option is enabled. The password that is returned by this method will not be stored locally in the application server.
Be aware that the application server will call this method to get the password for trusted context usage if the following is true:
- You set the useTrustedContextWithAuthentication data source custom property to true.
- You use the TrustedConnectionMapping login configuration.
- Parameters:
identityname- String: the identity of the connection to which the application server is switching and for which password is needed.realm- String: the realm name that is being used that can determine the identity of the user.- Returns:
- String password that will be used when switching trusted context identity to the specified user.
- Throws:
java.sql.SQLException
-
isTransientConnectionError
boolean isTransientConnectionError(java.sql.SQLException ex)
This method determines whether aSQLExceptionindicates a transient connection error. That means the current SQL operation can be retried on the existing connection, if the method returns true. Currently, implementation of this method is limited to JDBC 4.0 compliant drivers.- Parameters:
ex- theSQLExceptionto check.- Returns:
- true if the exception indicates a transient connection error, otherwise false.
- See Also:
SQLException
-
-