代码改变世界

Could not open JDBC Connection for transaction; nested exception is com.alibaba.druid.pool.GetConnection

2019-03-14 01:26  youxin  阅读(6700)  评论(0编辑  收藏  举报

Could not open JDBC Connection for transaction; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 3000, active 16, maxActive 16"

这个异常可能是因为druid连接池泄漏产生的异常。连接超时,active和maxActive相等,不能够创建新的连接,如果很长时间还获取不到,很有可能是连接池泄漏造成的,而且没有开启druid的超时回收导致的。

添加回收机制后,

#druid recycle
druid.removeAbandoned=true
druid.removeAbandonedTimeout=300

 druid.logAbandoned=true

 

置removeAbandoned对性能会有一些影响,建议怀疑存在泄漏之后再打开。在上面的配置中,如果连接超过300秒未关闭,就会被强行回收,并且日志记录连接申请时的调用堆栈。

 

https://my.oschina.net/haogrgr/blog/224010