日期:2014-05-19  浏览次数:20926 次

tomcat console打印出AbandonedObjectPool is used?
我用tomcat作为container,hibernate操作数据库,每次启动tomcat的时候都会在console中打印出如下信息
AbandonedObjectPool is used (org.apache.commons.dbcp.AbandonedObjectPool@37773777)
  LogAbandoned: true
  RemoveAbandoned: true
  RemoveAbandonedTimeout: 60
我上网查了一下,网友说的是 程序有连接没有关闭,需要要查看代码 把connection.close()
放到finally{
}里面。但是在我这里用的是hibernate操作数据库,不是由我自己来操作连接,况且每次我启动tomcat的时候,我的程序的连接应该关闭了阿。怎么每次都提示这个呢?

------解决方案--------------------
解决的办法有3个 

1重启你的服务器 

2在content.xml中,将maxActive设置为零,或者调高它的值 

3在你的程序中正确关闭connections 这里有一点要注意要把关闭的语句写在finally中,如果你写在try{}中出现异常的话是无法正确关闭的。 

要象这样 

} catch (SQLException e) { 
/** Exception handling **/ 
} finally { 
try { 
if (stmt != null) 
stmt.close(); 
if (dbConnection != null) 
dbConnection.close(); 
} catch (SQLException e) { 
/** Exception handling **/ 


当然这3个方法里前两个并不能从根本上解决你的问题,所以还是要好好研究你的程序,一定要将用完的connection放回到池中。