#46 DB2 driver problem (getHoldability fails), patch for 0.9.1.1

closed
None
5
2007-03-24
2007-03-21
Lari Hotari
No

When com.mchange.v2.c3p0.ComboPooledDataSource is used with DB2 Type 2 driver (COM.ibm.db2.jdbc.app.DB2Driver), acquiring a new connection from the pool fails in com.mchange.v3.c3p0.impl.NewPooledConnection on this line:
this.dflt_holdability = (supports_setHoldability ? con.getHoldability() : ResultSet.CLOSE_CURSORS_AT_COMMIT);

DB2 app driver throws an java.lang.Error when con.getHoldability gets called. (I've lost the original stack trace)

I've fixed the problem by using a similar "carefulcheck" solution that's used in checking the readonly or typemap attributes of the connection.

Changed lines:
this.dflt_holdability = (supports_setHoldability ? carefulCheckHoldability(con) : ResultSet.CLOSE_CURSORS_AT_COMMIT);

New method:
private static int carefulCheckHoldability(Connection con)
{
try { return con.getHoldability(); }
catch (Throwable e)
{
if (false)
{
if (logger.isLoggable(MLevel.FINER))
logger.log(MLevel.FINER, con + " threw an Exception when we tried to check its default " +
"holdability. This is not usually a problem! It just means the Connection " +
"doesn't support the holdability property, and c3p0 works around this.", e);
}
return ResultSet.CLOSE_CURSORS_AT_COMMIT;
}
}

"diff -u" patch file is attached. I hope that this patch goes in to the next version.

Discussion

  • Lari Hotari

    Lari Hotari - 2007-03-21

    Patches src/classes/com/mchange/v2/c3p0/impl/NewPooledConnection.java

     
  • Lari Hotari

    Lari Hotari - 2007-03-22
    • assigned_to: nobody --> swaldman
     
  • Steve Waldman

    Steve Waldman - 2007-03-24

    Logged In: YES
    user_id=175530
    Originator: NO

    Lari,

    Many thanks for finding the problem, and implementing the fix.

    It will be in the next minor release of c3p0.

    Thanks again!

     
  • Steve Waldman

    Steve Waldman - 2007-03-24
    • status: open --> closed
     
  • Steve Waldman

    Steve Waldman - 2007-03-24

    Logged In: YES
    user_id=175530
    Originator: NO

    I've complicated things a bit, 'cuz I'm not comfortable swallowing Throwables without logging something about it... so you'll see one message at WARNING level the first time c3p0 encounters this error, after which c3p0 will suppress getHoldabity() Errors as long as the Connection implementation class and Error class have not changed. But, other than that, it's in there.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks