原文链接
由于连接未关闭,导致的连接池连接被拿完.
1.把log4j.properties设置成debug
log4j.rootLogger=debug, file, console, safe
2.c3p0-config.xml设置
<!-- 最大空闲时间,若为0则永不丢弃。Default: 0 -->
<property name="maxIdleTime">60</property>
<!-- 自动超时回收,根据最大空闲时间设置,超过maxIdleTime则缓冲池自动清除链接 -->
<property name="unreturnedConnectionTimeout">80</property>
<!-- 跟踪泄露 -->
<property name="debugUnreturnedConnectionStackTraces">true</property>
3.通过Overdue resource check-out stack trace确定异常位置
解决连接池溢出问题
本文详细介绍了如何解决因连接未关闭导致的连接池溢出问题。通过调整log4j配置到debug级别,优化c3p0配置参数如maxIdleTime、unreturnedConnectionTimeout和debugUnreturnedConnectionStackTraces,以及使用Overdueresourcecheck-outstacktrace定位异常位置,有效避免了连接池资源的浪费。
1668

被折叠的 条评论
为什么被折叠?



