Class InformixDataStoreHelper
- java.lang.Object
-
- com.ibm.websphere.rsadapter.GenericDataStoreHelper
-
- com.ibm.websphere.rsadapter.InformixDataStoreHelper
-
- All Implemented Interfaces:
- DataStoreHelper
public class InformixDataStoreHelper extends GenericDataStoreHelper
InformixDataStoreHelper
is aDataStoreHelper
implementation customized for the Informix database. When mapping aSQLException
, theSQLException
mappings from theInformixDataStoreHelper
are searched first, and subsequently, if no match is found, theSQLException
mappings from theGenericDataStoreHelper
are searched. If you have additional requirements on Informix, consider subclassing this implementation.
Note: This class and its methods can not be called or referenced directly by user applications.SQLException
mappings specific to theInformixDataStoreHelper
are the following:Error Code SQL State PortableSQLException
subclass-79735 StaleConnectionException.class
-79716 StaleConnectionException.class
-43207 StaleConnectionException.class
-27002 StaleConnectionException.class
-25580 StaleConnectionException.class
-908 StaleConnectionException.class
-710 StaleStatementException.class
-268 DuplicateKeyException.class
43012 StaleConnectionException.class
-
-
Field Summary
-
Fields inherited from class com.ibm.websphere.rsadapter.GenericDataStoreHelper
customDefinedWasDefaultIsoLevel, defaultQueryTimeout, EOLN, genErrorMap, resBundle, tranErrorList
-
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 and Description InformixDataStoreHelper(java.util.Properties props)
ThisInformixDataStoreHelper
constructor creates a newInformixDataStoreHelper
based on theDataStoreHelper
properties provided.
-
Method Summary
Methods Modifier and Type Method and Description void
doConnectionSetup(java.sql.Connection conn)
This method configures a connection before first use.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 theInformixDataStoreHelper
,GenericDataStoreHelper
, and user-definedSQLException
maps.int
getIsolationLevel(AccessIntent aIntent)
This method determines the transaction isolation level based on the specifiedAccessIntent
.java.io.PrintWriter
getPrintWriter()
This method is used to obtain thejava.io.PrintWriter
to use for logging when database logging is enabled (for example:WAS.database=all=enabled
).int
getResultSetConcurrency(AccessIntent intent)
This method determines the result set concurrency based on the specifiedAccessIntent
.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, doConnectionSetupPerGetConnection, doConnectionSetupPerTransaction, getLockType, getMetaData, getPasswordForUseWithTrustedContextWithAuthentication, getResultSetType, getXAExceptionContents, hasLostUpdateOrDeadLockOccurred, isBatchUpdateSupportedWithAccessIntent, isConnectionError, isDuplicateKey, isTransientConnectionError, isUnsupported, mapException, modifyXAFlag, setConfig, showLockInfo
-
-
-
-
Constructor Detail
-
InformixDataStoreHelper
public InformixDataStoreHelper(java.util.Properties props)
This
InformixDataStoreHelper
constructor creates a newInformixDataStoreHelper
based on theDataStoreHelper
properties provided.The
DataStoreHelper
properties forInformixDataStoreHelper
include an integer property,informixLockModeWait
, representing Informix's timeout when waiting for a lock. A value greater than 0 indicates the number of seconds Informix waits for a lock, after which Informix throws an exception. A value of 0 means Informix does not wait for locks at all, immediately throwing an exception. A value less than 0 means Informix waits indefinitely, until the lock it is waiting for is released. Informix's default behavior is to immediately throw an exception. However, WebSphere's default setting forinformixLockModeWait
is 2, meaning Informix waits for a lock for two seconds before throwing an exception.- Parameters:
props
-DataStoreHelper
properties.
-
-
Method Detail
-
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 theInformixDataStoreHelper
,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 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 aIntent) throws javax.resource.ResourceException
This method determines the transaction isolation level based on the specifiedAccessIntent
. If theAccessIntent
parameter is null, a default value is returned that is appropriate for the database backend. The default transaction isolation level forInformixDataStoreHelper
isConnection.TRANSACTION_REPEATABLE_READ.
In the case where an
AccessIntent
is specified,InformixDataStoreHelper
computes the transaction isolation level as follows:If the concurrency control is
AccessIntent.CONCURRENCY_CONTROL_OPTIMISTIC
, a transaction isolation level ofConnection.TRANSACTION_READ_COMMITTED
is returned.If the concurrency control is
AccessIntent.CONCURRENCY_CONTROL_PESSIMISTIC
and the access type isAccessIntent.ACCESS_TYPE_READ
, a transaction isolation level ofConnection.TRANSACTION_REPEATABLE_READ
is returned.If the concurrency control is
AccessIntent.CONCURRENCY_CONTROL_PESSIMISTIC
and the access type isAccessIntent.ACCESS_TYPE_UPDATE
, the transation isolation level is determined from the following table based on the pessimistic update lock hint.pessimistic update lock hint transaction isolation level AccessIntent.PESSIMISTIC_UPDATE_LOCK_HINT_NONE
AccessIntent.PESSIMISTIC_UPDATE_LOCK_HINT_WEAKEST_LOCK_AT_LOAD
Connection.TRANSACTION_REPEATABLE_READ
AccessIntent.PESSIMISTIC_UPDATE_LOCK_HINT_NOCOLLISION
Connection.TRANSACTION_READ_COMMITTED
AccessIntent.PESSIMISTIC_UPDATE_LOCK_HINT_EXCLUSIVE
Connection.TRANSACTION_SERIALIZABLE
- Specified by:
getIsolationLevel
in interfaceDataStoreHelper
- Overrides:
getIsolationLevel
in classGenericDataStoreHelper
- 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
.- See Also:
AccessIntent
,Connection
-
getResultSetConcurrency
public int getResultSetConcurrency(AccessIntent intent) throws javax.resource.ResourceException
This method determines the result set concurrency based on the specifiedAccessIntent
.InformixDataStoreHelper
always returnsjava.sql.ResultSet.CONCUR_READ_ONLY
.- Specified by:
getResultSetConcurrency
in interfaceDataStoreHelper
- Overrides:
getResultSetConcurrency
in classGenericDataStoreHelper
- 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
.- See Also:
AccessIntent
,ResultSet
-
doConnectionSetup
public void doConnectionSetup(java.sql.Connection conn) throws java.sql.SQLException
This 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.
The following actions are prohibited in this method:
- Changing any standard connection properties found on the
java.sql.Connection
API. This includes TransactionIsolationLevel, AutoCommit, Catalog, ReadOnly, TypeMap, and Holdability. - Closing the connection.
The
InformixDataStoreHelper
configures the InformixLOCK MODE WAIT
based on theinformixLockModeWait
DataStoreHelper
property. A value greater than 0 indicates the number of seconds Informix waits for a lock, after which Informix throws an exception. TheinformixLockModeWait
value, 0, means Informix does not wait for locks at all, immediately throwing an exception. A value less than 0 means Informix waits indefinitely, until the lock it is waiting for is released. Informix's default behavior is to immediately throw an exception. However, WebSphere's default setting forinformixLockModeWait
is 2, meaning Informix waits for a lock for two seconds before throwing an exception.- Specified by:
doConnectionSetup
in interfaceDataStoreHelper
- Overrides:
doConnectionSetup
in classGenericDataStoreHelper
- Parameters:
conn
- the connection to set up.- Throws:
java.sql.SQLException
- if connection setup cannot be completed successfully.
- Changing any standard connection properties found on the
-
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 being cached. It is called only if at least one of the following statement properties has changed,
- cursorName
- fetchDirection
- maxFieldSize
- maxRows
- queryTimeout
InformixDataStoreHelper
resets all of the statement properties listed above except for thecursorName
property.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 can 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.
-
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 WebSphere 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. Invoke this method only fromDataStoreHelper
classes subclassing this class. Do not invoke this method directly from application code. Internal WebSphere code does not invoke this method.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
. 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
SQLException
is received with SQL State S1000 and Error Code 23505, the WebSphereDataStoreHelper
implementations map the exception toUserDefinedException
, whereas the WAS 4.0 DataSource map the exception toDuplicateKeyException
.Additionally, mapping done by the WebSphere
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. You can also useVoid.class
for the value, in which case any existing mapping for the specified SQL State or Error Code is removed.- See Also:
SQLException
,PortableSQLException
-
getPrintWriter
public java.io.PrintWriter getPrintWriter()
This method is used to obtain thejava.io.PrintWriter
to use for logging when database logging is enabled (for example:WAS.database=all=enabled
). By default, null is returned and ajava.io.PrintWriter
instance created by WebSphere is used. You can override this method to return a differentjava.io.PrintWriter
instance instead of the default.- Specified by:
getPrintWriter
in interfaceDataStoreHelper
- Overrides:
getPrintWriter
in classGenericDataStoreHelper
- Returns:
java.io.PrintWriter
.- Since:
- WAS 5.0.1
-
-