1

I am trying to use C3P0 connection pools for IBM DB2 Version 10.5.5 Fix Pack 5 with Java 8 .

Initially, I was getting this error so I changed jar to db2jcc4.jar but I still get below error in console,

1350 [C3P0PooledConnectionPoolManager[identityToken->2x0fal9iui9mpmdj6im3|c2e1f26]-HelperThread-#1] INFO  com.mchange.v2.c3p0.SQLWarnings  – Origination unknown: [10228][11541][4.11.77] Security exceptions occurred while loading driver. ERRORCODE=4223, SQLSTATE=null
com.ibm.db2.jcc.am.SqlWarning: Origination unknown: [10228][11541][4.11.77] Security exceptions occurred while loading driver. ERRORCODE=4223, SQLSTATE=null
    at com.ibm.db2.jcc.am.gd.b(gd.java:207)
    at com.ibm.db2.jcc.am.gd.b(gd.java:258)
    at com.ibm.db2.jcc.am.jb.a(jb.java:887)
    at com.ibm.db2.jcc.am.lb.a(lb.java:574)
    at com.ibm.db2.jcc.am.lb.<init>(lb.java:555)
    at com.ibm.db2.jcc.t4.b.<init>(b.java:305)
    at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:214)
    at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:460)
    at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
    at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
    at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
Caused by: java.security.PrivilegedActionException: java.lang.ClassNotFoundException: sun.io.ByteToCharConverter
    at java.security.AccessController.doPrivileged(Native Method)
    at com.ibm.db2.jcc.am.jb.r(jb.java:873)
    at com.ibm.db2.jcc.am.jb.<clinit>(jb.java:484)
    at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:117)
    ... 9 more
Caused by: java.lang.ClassNotFoundException: sun.io.ByteToCharConverter
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.ibm.db2.jcc.am.jg.run(jg.java:19)
    ... 13 more
1350 [C3P0PooledConnectionPoolManager[identityToken->2x0fal9iui9mpmdj6im3|c2e1f26]-HelperThread-#0] INFO  com.mchange.v2.c3p0.SQLWarnings  – Origination unknown: [10228][11541][4.11.77] Security exceptions occurred while loading driver. ERRORCODE=4223, SQLSTATE=null
com.ibm.db2.jcc.am.SqlWarning: Origination unknown: [10228][11541][4.11.77] Security exceptions occurred while loading driver. ERRORCODE=4223, SQLSTATE=null
    at com.ibm.db2.jcc.am.gd.b(gd.java:207)
    at com.ibm.db2.jcc.am.gd.b(gd.java:258)
    at com.ibm.db2.jcc.am.jb.a(jb.java:887)
    at com.ibm.db2.jcc.am.lb.a(lb.java:574)
    at com.ibm.db2.jcc.am.lb.<init>(lb.java:555)
    at com.ibm.db2.jcc.t4.b.<init>(b.java:305)
    at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:214)
    at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:460)
    at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
    at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
    at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
Caused by: java.security.PrivilegedActionException: java.lang.ClassNotFoundException: sun.io.ByteToCharConverter
    at java.security.AccessController.doPrivileged(Native Method)
    at com.ibm.db2.jcc.am.jb.r(jb.java:873)
    at com.ibm.db2.jcc.am.jb.<clinit>(jb.java:484)
    at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:117)
    ... 9 more
Caused by: java.lang.ClassNotFoundException: sun.io.ByteToCharConverter
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.ibm.db2.jcc.am.jg.run(jg.java:19)
    ... 13 more

Even if this error is present in logs, my stand alone Java app is able to make connections to database and gets results i.e. SELECT query is executed successfully.

How to fix this confusion?

Community
  • 1
  • 1
Sabir Khan
  • 9,826
  • 7
  • 45
  • 98

1 Answers1

1

The stack traces you are seeing come from SqlWarning objects, which probably means they are not fatal or serious problems. The apparent problem java.lang.ClassNotFoundException: sun.io.ByteToCharConverter seems pretty strange. But since it is coming through as a warning rather than thrown as an Exception, the driver has probably recovered from the problem, which is why your application seems to work.

JDBC Connections are permitted to store a chain of SQLWarnings, which might arise from anything, but which most applications simply ignore. (Most JDBC programmers are unaware they even exist.)

c3p0 is extremely neurotic about periodically checking for Connection warnings, logging them, and then clearing them, so that users of Connections don't see warnings derived from prior clients' uses. The logging of warnings can be annoying, though, so if you want, it is easy to suppress it (or redirect it to a separate file, or whatever). c3p0 logs warnings to a special logger named com.mchange.v2.c3p0.SQLWarnings. In the configuration file for whatever logging library you use, you can suppress this output by setting that logger's level to WARNING or above.

(A bit confusingly SQLWarnings are logged at INFO not WARNING. Since they usually represent information about conditions already recovered from, which driver authors understand that most developers never see, they don't substantively rise to the level of WARNING. So filtering out messages from com.mchange.v2.c3p0.SQLWarnings at INFO and below is sufficient to quiet the warnings. If you'd like to see the responsible code, it is here.)

Tomasz Stanczak
  • 12,796
  • 1
  • 30
  • 32
Steve Waldman
  • 13,689
  • 1
  • 35
  • 45
  • Thank you !! Let me see if I can suppress these in logs. – Sabir Khan Aug 09 '16 at 07:17
  • Adding these two lines in c3p0.properties file turned off these logs , `com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL=WARNING com.mchange.v2.log.MLog=com.mchange.v2.log.FallbackMLog` – Sabir Khan Aug 09 '16 at 08:14
  • that would do it! but it will suppress all INFO level logging (not just for `com.mchange.v2.c3p0.SQLWarnings`), and force logging to standard error only. if your application is logging to slf4j or log4j or java.util.logging, it's best to let c3p0 log to the same place, and just suppress the log individually. (if your application is small and not using a full logging library, logging at WARNING to standard error, what you are doing right now, may be fine.) – Steve Waldman Aug 09 '16 at 08:19
  • The ClassNotFound does not seem so strange to me: sun.io.ByteToCharConverter was included in Java JDK 7, but is no longer in JDK 8. Of course, it is dubious that IBM uses this internal JDK class in its driver. This is likely (hopfully?) to be fixed in a future driver version. – JRA_TLL Apr 13 '17 at 12:51
  • According to https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.qb.server.doc/doc/r0011932.html, the IBM dirver for DB2 V10.5 does support Java 6&7 only, starting from DB2 V11.1.0 Java 8 is also supported. – JRA_TLL Apr 13 '17 at 13:10