at org.enhydra.jdbc.pool.GenericPool.getFromPool(GenericPool.java:200)
at org.enhydra.jdbc.pool.GenericPool.checkOut(GenericPool.java:351)
at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:194)
at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:164)
at my.jotm.test.Client.getConnection(Client.java:63)
java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in
StandardPoolDataSource:getConnection no connection available java.lang.NullPointerException
发现这是XApool1.5的一个bug
解决方法:
--- xapool/org/enhydra/jdbc/pool/GenericPool.java-1.13 2005-06-14 21:57:10.756790600 -0500
+++ xapool/org/enhydra/jdbc/pool/GenericPool.java 2005-06-15 13:11:09.601072300 -0500
@@ -189,6 +189,12 @@
o = (GenerationObject) e.nextElement();
life = (Long) unlocked.get(o);
+ if (life == null) {
+ // Fix for #303462; note that this fixes the problem, but Enumeration's on Hashtable's
+ // are by definition somewhat unpredictable; a more robust fix may be in order
+ log.debug("GenericPool:getFromPool fix for #303462 encountered");
+ continue;
+ }
unlocked.remove(o);
// In any case the object will be removed.
// Prevents others accessing the object while we are
下载xapool源码包,然后在org.enhydra.jdbc.pool.GenericPool中,找到life = (Long) unlocked.get(o); 代码
之后在下面加入:
if (life == null) continue;
之后重新编译打包即可。
注:xapool1.5是在jdk1.4的版本下编译的,所以记得在打包修改时,将IDE的J2SE版本改为1.4。
以下提供我已经编译好的jar包,使用中如果看到bad version的错误,请自行编译。
本文介绍了 XAPool 1.5 版本中的一个连接池 bug,该 bug 导致无法获取数据库连接并抛出 NullPointerException。文中详细解释了 bug 的原因,并提供了具体的解决方案,包括代码修改和重新编译打包的方法。
3366

被折叠的 条评论
为什么被折叠?



