我正在尝试将 IBM DB2 Version 10.5.5 Fix Pack 5 的C3P0
连接池与Java 8一起使用。
最初,我收到了this error所以我将jar更改为db2jcc4.jar
,但我仍然在控制台中遇到错误,
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
即使日志中存在此错误,我的独立Java应用程序也能够连接到数据库并获得结果,即SELECT查询成功执行。
如何解决这种混乱?
答案 0 :(得分:1)
您看到的堆栈跟踪来自SqlWarning对象,这可能意味着它们不是致命或严重问题。明显的问题java.lang.ClassNotFoundException: sun.io.ByteToCharConverter
似乎很奇怪。但是,由于它是作为警告而不是作为异常引发的,因此驱动程序可能已从问题中恢复,这就是您的应用程序似乎有用的原因。
允许JDBC连接存储a chain of SQLWarnings,这可能来自任何东西,但大多数应用程序都忽略了。 (大多数JDBC程序员都不知道它们甚至存在。)
c3p0对于定期检查连接警告,记录它们,然后清除它们非常神经质,因此Connections用户看不到先前客户端使用的警告。但是,警告的记录可能很烦人,因此如果您愿意,可以很容易地将其抑制(或将其重定向到单独的文件或其他任何内容)。 c3p0将警告记录到名为com.mchange.v2.c3p0.SQLWarnings
的特殊记录器。在您使用的任何日志记录库的配置文件中,您可以通过将记录器的级别设置为WARNING
或更高来抑制此输出。
(有点令人困惑的是,INFO
而不是WARNING
记录了SQLWarning。由于它们通常代表已经从中恢复的条件的信息,哪些驱动程序作者理解大多数开发人员从未看到过,因此它们实质上没有上升到WARNING
的级别。因此,在com.mchange.v2.c3p0.SQLWarnings
及以下过滤来自INFO
的邮件足以使警告静音。如果您想查看负责的代码,则为{{ 3}}。)