[jira] Created: (DBCP-237) InstanceKeyDataSource.getConnection, exception during setup Defaults()

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (DBCP-237) InstanceKeyDataSource.getConnection, exception during setup Defaults()

JIRA jira@apache.org
InstanceKeyDataSource.getConnection, exception during setup Defaults()
----------------------------------------------------------------------

                 Key: DBCP-237
                 URL: https://issues.apache.org/jira/browse/DBCP-237
             Project: Commons Dbcp
          Issue Type: Bug
    Affects Versions: 1.2.1
         Environment: Sybase jConnect2 5.5, spring framework 2.0.1
            Reporter: Oliver Matz


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;
}


--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (DBCP-237) InstanceKeyDataSource.getConnection, exception during setup Defaults()

JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/DBCP-237?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Phil Steitz updated DBCP-237:
-----------------------------

    Fix Version/s: 1.3

> InstanceKeyDataSource.getConnection, exception during setup Defaults()
> ----------------------------------------------------------------------
>
>                 Key: DBCP-237
>                 URL: https://issues.apache.org/jira/browse/DBCP-237
>             Project: Commons Dbcp
>          Issue Type: Bug
>    Affects Versions: 1.2.1
>         Environment: Sybase jConnect2 5.5, spring framework 2.0.1
>            Reporter: Oliver Matz
>             Fix For: 1.3
>
>
> 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;
> }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (DBCP-237) InstanceKeyDataSource.getConnection, exception during setup Defaults()

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/DBCP-237?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Phil Steitz updated DBCP-237:
-----------------------------

    Affects Version/s: 1.2.2

> InstanceKeyDataSource.getConnection, exception during setup Defaults()
> ----------------------------------------------------------------------
>
>                 Key: DBCP-237
>                 URL: https://issues.apache.org/jira/browse/DBCP-237
>             Project: Commons Dbcp
>          Issue Type: Bug
>    Affects Versions: 1.2.1, 1.2.2
>         Environment: Sybase jConnect2 5.5, spring framework 2.0.1
>            Reporter: Oliver Matz
>             Fix For: 1.3
>
>
> 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;
> }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (DBCP-237) InstanceKeyDataSource.getConnection, exception during setup Defaults()

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/DBCP-237?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Phil Steitz resolved DBCP-237.
------------------------------

    Resolution: Fixed

Patch with tests applied in r618163.
Thanks!

> InstanceKeyDataSource.getConnection, exception during setup Defaults()
> ----------------------------------------------------------------------
>
>                 Key: DBCP-237
>                 URL: https://issues.apache.org/jira/browse/DBCP-237
>             Project: Commons Dbcp
>          Issue Type: Bug
>    Affects Versions: 1.2.1, 1.2.2
>         Environment: Sybase jConnect2 5.5, spring framework 2.0.1
>            Reporter: Oliver Matz
>             Fix For: 1.3
>
>
> 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;
> }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.