|
Handling Connection ErrorsA problem with pooled connections is errors on the underlying database connection can disrupt the operation of the pool or the application. The pool implementation provides mechanisms for reducing the impact of these errors. Validate on AllocationOne issue that can disrupt the operation of an application is if the connection returned from the pool is actually unusable; for example, it may have been closed by the underlying driver due to a network problem. As a result, the first time the application tries to use the connection, the operation will fail, potentially leading to complete rollback of the transaction. To avoid this, the connector can be configured to execute an SQL statement on the connection before returning it to the application. If this fails, then the connection is immediately discarded and the next one in the pool is considered. To enable this check, use the An example of this configuration for an Oracle database could be:
Detecting Fatal ExceptionsCertain SQLExceptions thrown by the JDBC driver indicate a fatal error condition under which all future operations on the Connection will fail. Further, even though such a SQLException may cause the current transaction to be rolled back, the Connection will be returned to the pool and may be returned again to the application. Unfortunately, there is no standard way of telling which SQLExceptions indicate these fatal errors, and, further, the actual implementation varies between databases and even drivers. To allow the detection of these conditions, the JCA adaptor allows an Exception Sorter to be associated with the datasource. If a SQLException is thrown, then it will be passed to the Exception Sorter to determine if it should be considered fatal; is so, then the connection will immediately be discarded from the pool. An Exception Sorter is an implementation of the interface: package org.jboss.resource.adapter.jdbc; which is associated with a datasource using the
The following pre-configured implementations are available:
|
|
||||||||||
© 2003 Core Developers Network Ltd "Core Developers Network", the stylized apple logo and "Core Associates" are trademarks of Core Developers Network Ltd. All other trademarks are held by their respective owners. Core Developers Network Ltd is not affiliated with any of the respective trademark owners. |