Tomcat连接池报错:DBCP object created by the following code was never closed:

DBCP object created 2012-05-16 13:31:27 by the following code was never closed:
java.lang.Exception
    at org.apache.commons.dbcp.AbandonedTrace.setStackTrace(AbandonedTrace.java:160)
    at org.apache.commons.dbcp.AbandonedObjectPool.borrowObject(AbandonedObjectPool.java:86)
    at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:96)
    at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
    at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
    at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
    at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)

经查,这是removeAbandoned=true导致的,使用这个配置的时候将会使用AbandonedObjectPool.
而AbandonedObjectPool建议只在开发阶段使用,因为AbandonedObjectPool能帮你发现占用连接过长的代码.比如这个log信息,说明了getCustomerOnline占用连接超过
                  removeAbandonedTimeout设定的时间.所以设置removeAbandoned=false就行了。 AbandonedObjectPool只在开发使用,在后续版本会去掉,现在api都deprecated了.这个功能太容易被误用了!

 

你可能感兴趣的:(Tomcat连接池报错:DBCP object created by the following code was never closed:)