Dbcp2抛出org.apache.commons.dbcp2.LifetimeExceededException

 1 三月 24, 2016 5:16:33 下午 org.apache.commons.dbcp2.BasicDataSource onSwallowException
 2 警告: An internal object pool swallowed an Exception.
 3 org.apache.commons.dbcp2.LifetimeExceededException: The lifetime of the connection [14] milliseconds exceeds the maximum permitted value of [10] milliseconds
 4     at org.apache.commons.dbcp2.PoolableConnectionFactory.validateLifetime(PoolableConnectionFactory.java:424)
 5     at org.apache.commons.dbcp2.PoolableConnectionFactory.passivateObject(PoolableConnectionFactory.java:364)
 6     at org.apache.commons.pool2.impl.GenericObjectPool.returnObject(GenericObjectPool.java:581)
 7     at org.apache.commons.dbcp2.PoolableConnection.close(PoolableConnection.java:206)
 8     at org.apache.commons.dbcp2.DelegatingConnection.closeInternal(DelegatingConnection.java:235)
 9     at org.apache.commons.dbcp2.DelegatingConnection.close(DelegatingConnection.java:218)
10     at org.apache.commons.dbcp2.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:244)
11     at org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)
12     at org.apache.commons.dbutils.AbstractQueryRunner.close(AbstractQueryRunner.java:438)
13     at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:359)
14     at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:307)
15     at com.starunion.java.fsccserver.dao.DbUtilsTemplate.getCount(DbUtilsTemplate.java:188)
16     at com.starunion.java.fsccserver.dao.fs.DaoCdrInfo.getSessionCount(DaoCdrInfo.java:33)
17     at com.starunion.java.fsccserver.service.client.ProcClientReqSql.getCdrSessionCount(ProcClientReqSql.java:45)
18     at com.starunion.java.fsccserver.service.client.ClientReqMsgLogicService.procClientRequest(ClientReqMsgLogicService.java:114)
19     at com.starunion.java.fsccserver.thread.client.SocketClientTcpThread.run(SocketClientTcpThread.java:99)

一、结合我的实际环境,推测这个抛出的原因:

可能是数据库建立链接的时候身份验证的时候超时。

推测依据:

观察数据库链接的建立状态,总是出现花1-5秒的时间。

二、进一步测试,觉得原因【不是建链】时候的超时。

应该是数据库查询(操作)的时间超时,推测依据:

通过mysql后台执行的操作显示时间花费0.02s或者更多的时候,这个抛出一定出现。

符合抛出显示>10ms的条件。

那就应该有设置,不可能要求所有的数据库操作时间花费都小于10ms吧?

或者是个BUG?

但是不影响返回后面的查询结果,所以……这个问题先放一放吧。

或者谁能帮我解答一下?