Issue Details (XML | Word | Printable)

Key: DBCP-237
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Oliver Matz
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Commons Dbcp

InstanceKeyDataSource.getConnection, exception during setup Defaults()

Created: 20/Aug/07 11:20 AM   Updated: 25/Mar/08 08:11 AM
Return to search
Component/s: None
Affects Version/s: 1.2.1, 1.2.2
Fix Version/s: 1.3

Time Tracking:
Not Specified

Environment: Sybase jConnect2 5.5, spring framework 2.0.1

Resolution Date: 04/Feb/08 04:00 AM


 Description  « Hide
Problem in
org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(String username, String password)
if setupDefaults() throws an Exception, the connection will not get closed.
After a while, this will cause the following exception:
org.apache.commons.dbcp.SQLNestedException: Could not retrieve connection info from pool

This scenario can happen for Sybase jConnect2 5.5. The exception that may be thrown by jConnect2 is:
com.sybase.jdbc2.jdbc.SybConnectionDeadException: JZ0C0: Connection is already closed.

More details:
The last lines of the method are as follows:
-------
Connection con = info.getPooledConnection().getConnection();
setupDefaults(con, username);
con.clearWarnings();
return con;
-------

In my case, the exception happens in the second line of this snippet,
so no code gets the chance close con and release the resources.

I propose to change it to:

-------
Connection con = info.getPooledConnection().getConnection();
try
{
setupDefaults(con, username);
con.clearWarnings();
return con;
}
catch (Exception exc)
{
try

{ con.close(); }

catch (Exception exc)

{ getLogWriter().println("ignoring exception during close: " + exc); // uncertain here. }

throw exc;
}



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Phil Steitz made changes - 19/Nov/07 03:37 AM
Field Original Value New Value
Fix Version/s 1.3 [ 12311977 ]
Phil Steitz made changes - 30/Jan/08 04:58 AM
Affects Version/s 1.2.2 [ 12311976 ]
Phil Steitz made changes - 04/Feb/08 04:00 AM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Henri Yandell made changes - 25/Mar/08 08:11 AM
Status Resolved [ 5 ] Closed [ 6 ]