Menu

#603 JTDS broken with C3PO connection pool

closed
momo
Other (154)
5
2014-12-03
2009-11-18
Anonymous
No

Upgraded from 1.2.24=> 1.2.4, found hibernate (which uses C3P0) was hanging.

Wrote a test class and got the exception below

xception in thread "main" java.lang.NoClassDefFoundError: java/sql/NClob
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
at java.lang.Class.getMethod0(Class.java:2642)
at java.lang.Class.getMethod0(Class.java:2651)
at java.lang.Class.getMethod(Class.java:1579)
at com.mchange.v2.c3p0.impl.C3P0ImplUtils.supportsMethod(C3P0ImplUtils.java:309)
at com.mchange.v2.c3p0.impl.NewPooledConnection.<init>(NewPooledConnection.java:104)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:159)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:132)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.initializeAutomaticTestTable(C3P0PooledConnectionPoolManager.java:772)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.createPooledConnectionPool(C3P0PooledConnectionPoolManager.java:696)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.getPool(C3P0PooledConnectionPoolManager.java:257)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.getPool(C3P0PooledConnectionPoolManager.java:271)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
at com.gwava.db.DerbyUtil.main(DerbyUtil.java:345)</init>

Test code, using C3P0 .9.1.2 (or whatever is the latest)

ComboPooledDataSource MY_POOL= new ComboPooledDataSource("derby");
String DBDriver="net.sourceforge.jtds.jdbc.Driver";
Class.forName(DBDriver).newInstance();
MY_POOL.setDriverClass(DBDriver);
String url="jdbc:jtds:sqlserver://192.168.2.50:1433/retain";
String user="retainuser";
MY_POOL.setJdbcUrl(url);
MY_POOL.setUser(user);
MY_POOL.setPassword("1234"); // the settings below are optional -- c3p0 can work with defaults
MY_POOL.setMinPoolSize(3);
MY_POOL.setAcquireIncrement(3);
MY_POOL.setBreakAfterAcquireFailure(false);
MY_POOL.setAcquireRetryAttempts(10);
//MY_POOL.setAcquireRetryDelay(1000);
MY_POOL.setMaxPoolSize(50); // The DataSource cpds is now a fully configured and usable pooled DataSource ...
MY_POOL.setMaxIdleTimeExcessConnections(500); // if it spikes above 20, start killing unused connections after 5 mins

        Connection con=MY_POOL.getConnection();
        con.close();

Discussion

  • Anonymous

    Anonymous - 2009-11-18

    Sorry I meant to write

    "from JTDS 1.2.2 to JTDS 1.2.4"

     
  • Anonymous

    Anonymous - 2009-11-18

    Additional points:

    1. I am running Java 1.5
    2. The class in reference is a JDBC4 (JAVA 6) clas
    3. I believe this may be related to the glassfish issue.
    4. I am running Tomcat, so there's no workaround for me.
    5. This breaks C3P0, and hence many Hibernate deployments
     
  • momo

    momo - 2009-11-19

    As you pointed out, the missing class is part of JDBC 4/Java 6 and normally shouldn't be required as long as the corresponding method (createNClob()) is not invoked by an application. Obviously C3P0 uses reflection to scan the Connection implementation and in doing so stumbles across the JDBC 4 method stubs introduced in jTDS 1.2.3. Unfortunately, it seems adding those stubs involves more problems than initially expected. Even if the JDBC 4 stubs have been requested a number of times, removing them again may be the only feasible solution.

    That being said, there are two things one could do for the time being:

    a) use a Java 6 VM
    b) put the JDBC 4 interfaces in the classpath

    Cheers,
    momo

     
  • Anonymous

    Anonymous - 2009-11-20

    a) I cannot use a Java 6 VM for about 1 year
    b) Not sure what you are suggesting here
    c) It might be best to have an ant build script that builds two binary jars, one with the jdbc4 stubs, one without. It seems other projects (PostgresSQL and I think Oracle) had to do the same (Although I believe MySQL managed it all in one)

     

    Last edit: Anonymous 2014-09-07
  • momo

    momo - 2009-12-30

    This problem has been fixed in CVS. An Ant build script removes the JDBC4 method stubs before compiling.

     

Log in to post a comment.

MongoDB Logo MongoDB