Bug #56200 Add diagnostic information to SQLException message when closed connection used
Submitted: 23 Aug 2010 22:29 Modified: 16 Dec 2011 8:06
Reporter: Todd Farmer (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.13 OS:Any
Assigned to: Todd Farmer CPU Architecture:Any

[23 Aug 2010 22:29] Todd Farmer
Description:
Load-balanced connections can be explicitly or implicitly closed when any of the following happen:

1.  Connection.close() is called explicitly by the application/framework/pool
2.  The connection is pinged (statement starting with "/* ping */") and either of the following happens:
2a:  The currently-selected physical connection fails ping (unknown transactional state)
2b:  None of the active physical connections can be pinged successfully
3.  C/J attempts to rebalance physical connections, but cannot establish a successful connection within X number of tries (where X is the number of configured hosts).

While all but the third cause are visible to the application (either in the form of Exceptions thrown for #2 or explicit application calls to Connection.close() for #1), the fact that all three result in the same SQLException message when the closed connection is later reused can make diagnosis of root cause difficult.

How to repeat:
See code.

Suggested fix:
Add diagnostic information to SQLException messages caused by subsequent usage of a closed load-balanced connection, such that the root cause of connection closure is readily apparent.
[3 May 2011 14:10] Mark Matthews
Fixed in 5.1.14.
[16 Dec 2011 8:06] Philip Olson
The 5.1.14 changelog entry:

+        Added diagnostic information to SQLException
+        messages that are caused by usage of a closed load-balanced
+        connection, to help clarify the root cause of a connection
+        closure.