XApool连接池报空指针错误解决

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的错误,请自行编译。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值