Exceptions pertaining to data access


 

+

Search Tips   |   Advanced Search

 

All enterprise bean container-managed persistence (CMP) beans under the EJB 2.x spec receive a standard EJB exception when an operation fails. JDBC applications receive a standard SQL exception if any JDBC operation fails. WAS ND v7.0 provides special exceptions for its relational resource adapter (RRA), to indicate that the connection currently held is no longer valid.

The connection wait timeout exception indicates that the application has waited for the number of seconds specified by the connection timeout setting and has not received a connection.

This situation can occur when the pool is at maximum size and all of the connections are in use by other applications for the duration of the wait. In addition, there are no connections currently in use that the application can share because either the connection properties do not match, or the connection is in a different transaction.

For a V 4.0 data source, the ConnectionWaitTimeout object creates an exception that is instantiated from the class...

com.ibm.ejs.cm.pool.ConnectionWaitTimeoutException

For J2C connection factories, the ConnectionWaitTimeout object generates a resource exception of the class...

com.ibm.websphere.ce.j2c.ConnectionWaitTimeoutException

When the error detection model is configured to exception mapping, later versions of data sources issue an SQL exception of the subclass...

com.ibm.websphere.ce.cm.ConnectionWaitTimeoutException

When the error detection model is configured to exception checking, later versions of data sources issue an SQL exception of the class...

java.sql.SQLTransientConnectionException
with a chained exception of the class...

com.ibm.websphere.ce.cm.ConnectionWaitTimeoutException

When the error detection model is configured to exception mapping, the stale connection exception indicates that the connection is no longer valid. When the error detection model is configured to exception checking, the JDBC driver raises a JDBC 4.0 exception, such as...

java.sql.SQLRecoverableException
java.sql.SQLNonTransientConnectionException

...or the JDBC driver specifies an appropriate SQLState to indicate that the connection is no longer valid.

New feature: V7.0 includes a new custom property for the data sources called userDefinedErrorMap. This property overlays existing entries in the error map by invoking the DataStoreHelper.setUserDefinedMap method. The userDefinedErrorMap can be used to add, change, or remove entries from the error map.

For example, to remove the mapping of SQLState S1000, add a mapping of error code 1062 to duplicate key, and add a mapping of SQLState 08004 to stale connection, we can specify the following value for userDefinedErrorMap:

"S1000"=;1062=com.ibm.websphere.ce.cm.DuplicateKeyException;"08004"=
com.ibm.websphere.ce.cm.StaleConnectionException
userDefinedErrorMap can be located in the admin console by selecting the data source and configuring the custom properties



Subtopics


Stale connections Example: Handling data access exception - ConnectionWaitTimeoutException (for the JDBC API)
Example: Handling data access exception - ConnectionWaitTimeoutException (for Java EE Connector Architecture)
Example: Handling data access exception - error mapping in DataStoreHelper
Database deadlock and foreign key conflicts

 

Related concepts


Data sources
Relational resource adapters and JCA

 

Related


Connection considerations when migrating servlets, JSPs, or enterprise session beans
JDBC trace configuration
Connection pool settings
Connection pool (V4) settings