Class DerbyDataStoreHelper
- java.lang.Object
-
- com.ibm.websphere.rsadapter.GenericDataStoreHelper
-
- com.ibm.websphere.rsadapter.DerbyDataStoreHelper
-
- All Implemented Interfaces:
DataStoreHelper
- Direct Known Subclasses:
DerbyNetworkServerDataStoreHelper
public class DerbyDataStoreHelper extends GenericDataStoreHelper
DerbyDataStoreHelper
is aDataStoreHelper
implementation customized for the Derby database. When mapping aSQLException
, theSQLException
mappings from theDerbyDataStoreHelper
are searched first, and subsequently, if no match is found, theSQLException
mappings from theGenericDataStoreHelper
are searched. If you have additional requirements on Derby you should consider subclassing this implementation.
Note: This class and its methods can not be called or referenced directly by user applications.SQLException
mappings specific to theDerbyDataStoreHelper
are the following:Error Code SQL State PortableSQLException
subclass40000 StaleConnectionException.class
45000 StaleConnectionException.class
50000 StaleConnectionException.class
23505 DuplicateKeyException.class
23500 DuplicateKeyException.class
23L01 DuplicateKeyException.class
XCL10 StaleStatementException.class
-
-
Field Summary
-
Fields inherited from interface com.ibm.websphere.rsadapter.DataStoreHelper
CLOUDSCAPE_HELPER, CLOUDSCAPE_NETWORK_SERVER_HELPER, CONNECTJDBC_HELPER, CUSTOM_HELPER, DATADIRECT_HELPER, DB2_390_HELPER, DB2_390_LOCAL_HELPER, DB2_400_HELPER, DB2_HELPER, DB2_UNIVERSAL_HELPER, DERBY_HELPER, DERBY_NETWORK_SERVER_HELPER, FIRST_TIME_CALLED, GENERIC_HELPER, INFORMIX_HELPER, INFORMIX_JCC_HELPER, MSSQL_HELPER, ORACLE_10G_HELPER, ORACLE_11G_HELPER, ORACLE_HELPER, POTENTIAL_DEADLOCK, POTENTIAL_LOST_UPDATE, PROXY_DS_HELPER, SEQUELINK_HELPER, SUBJECT, SYBASE_HELPER, SYBASE11_HELPER, TX_REPEATABLE_READ_FORUPDATE, TX_SERIALIZABLE_FORUPDATE, UNDEFINED_HELPER, UNDEFINED_ISOLATOIN_LEVEL, UPDATE_ON_READONLY
-
-
Constructor Summary
Constructors Constructor Description DerbyDataStoreHelper(java.util.Properties props)
ThisDerbyDataStoreHelper
constructor creates a newDerbyDataStoreHelper
based on theDataStoreHelper
properties provided.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doStatementCleanup(java.sql.PreparedStatement stmt)
This method cleans up a statement before the statement is returned to the statement cache.java.lang.Class
findMappingClass(java.sql.SQLException e)
This method locates thecom.ibm.websphere.ce.cm.PortableSQLException
subclass corresponding to the specifiedSQLException
, as defined by theDerbyDataStoreHelper
,GenericDataStoreHelper
, and user-definedSQLException
maps.int
getIsolationLevel(AccessIntent intent)
This method determines the transaction isolation level to use as default for the database backend.void
setUserDefinedMap(java.util.Map newmap)
This method configures a user-definedSQLException
map that supersedes defaultSQLException
mappings for theDataStoreHelper
.-
Methods inherited from class com.ibm.websphere.rsadapter.GenericDataStoreHelper
calcPartitionNumber, doConnectionCleanup, doConnectionCleanupPerCloseConnection, doConnectionCleanupWithValidCheck, doConnectionSetup, doConnectionSetupPerGetConnection, doConnectionSetupPerTransaction, getLockType, getMetaData, getPasswordForUseWithTrustedContextWithAuthentication, getPrintWriter, getResultSetConcurrency, getResultSetType, getXAExceptionContents, hasLostUpdateOrDeadLockOccurred, isBatchUpdateSupportedWithAccessIntent, isConnectionError, isDuplicateKey, isTransientConnectionError, isUnsupported, mapException, modifyXAFlag, setConfig, showLockInfo
-
-
-
-
Constructor Detail
-
DerbyDataStoreHelper
public DerbyDataStoreHelper(java.util.Properties props)
ThisDerbyDataStoreHelper
constructor creates a newDerbyDataStoreHelper
based on theDataStoreHelper
properties provided. All implementations inheriting from a data store helper must supply this same list of properties to their super class by invoking the constructor of their super class with the list of properties.- Parameters:
props
-DataStoreHelper
properties.
-
-
Method Detail
-
doStatementCleanup
public void doStatementCleanup(java.sql.PreparedStatement stmt) throws java.sql.SQLException
This method cleans up a statement before the statement is returned to the statement cache. This method is called only for statements that will be cached. It is called only if at least one of the following statement properties has changed,
- cursorName
- fetchDirection
- maxFieldSize
- maxRows
- queryTimeout
DerbyDataStoreHelper
resets all of the statement properties listed above.The following operations do not need to be included in the statement cleanup since they are automatically performed by WebSphere when caching statements,
setFetchSize(0)
clearParameters()
clearWarnings()
A helper class implementing this method may choose to do additional cleanup for the statement. However, this should never include closing the statement, since the statement is intended to be cached.
- Specified by:
doStatementCleanup
in interfaceDataStoreHelper
- Overrides:
doStatementCleanup
in classGenericDataStoreHelper
- Parameters:
stmt
- the PreparedStatement.- Throws:
java.sql.SQLException
- if an error occurs cleaning up the statement.
-
findMappingClass
public final java.lang.Class findMappingClass(java.sql.SQLException e)
This method locates the
com.ibm.websphere.ce.cm.PortableSQLException
subclass corresponding to the specifiedSQLException
, as defined by theDerbyDataStoreHelper
,GenericDataStoreHelper
, and user-definedSQLException
maps. Precedence and related details ofSQLException
mapping are described on theDataStoreHelper.setUserDefinedMap
method.Overriding this method is one of three options you have for modifying
SQLException
mapping. The other two options are overriding themapException
method and invoking thesetUserDefinedMap
method to add a user-definedSQLException
map.- Overrides:
findMappingClass
in classGenericDataStoreHelper
- Parameters:
e
- TheSQLException
for which to locate acom.ibm.websphere.ce.cm.PortableSQLException
subclass.- Returns:
- The
com.ibm.websphere.ce.cm.PortableSQLException
subclass matching theSQLException
, or null if no match was found. - See Also:
SQLException
,PortableSQLException
-
getIsolationLevel
public int getIsolationLevel(AccessIntent intent) throws javax.resource.ResourceException
This method determines the transaction isolation level to use as default for the database backend. The default transaction isolation level forDerbyDataStoreHelper
isConnection.TRANSACTION_REPEATABLE_READ.
- Specified by:
getIsolationLevel
in interfaceDataStoreHelper
- Overrides:
getIsolationLevel
in classGenericDataStoreHelper
- Parameters:
intent
- always null in Liberty- Returns:
- A transaction isolation level appropriate for the specified database.
- Throws:
javax.resource.ResourceException
- If a transaction isolation level cannot be determined.
-
setUserDefinedMap
public final void setUserDefinedMap(java.util.Map newmap)
This method configures a user-defined
SQLException
map that supersedes defaultSQLException
mappings for theDataStoreHelper
. TheDataStoreHelper
implementations provided by the application server useSQLException
maps to detect fatal connection errors, as well as other specific types of connection errors. A customDataStoreHelper
can alter the default mappings by invoking this method. Do not invoke this method from a customDataStoreHelper
if you also configureidentifyException
for adataSource
. When you configureidentifyException
, 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
setUserDefinedMap
method: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
.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
SQLException
is received with SQL State S1000 and Error Code 23505, theDataStoreHelper
implementations map the exception toUserDefinedException
.Additionally, mapping done by the
DataStoreHelper
s does not include mapping by chained exceptions when no match is found for the original exception.- Specified by:
setUserDefinedMap
in interfaceDataStoreHelper
- Overrides:
setUserDefinedMap
in classGenericDataStoreHelper
- Parameters:
newmap
- a mapping ofSQLException
SQL States and Error Codes tocom.ibm.websphere.ce.cm.PortableSQLException
subclasses. 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 aSQLException
as the single parameter.Void.class
may also be used for the value, in which case any existing mapping for the specified SQL State or Error Code is removed.
-
-