tomcat:Cannot get a connection, pool exhausted
Posted on 2010-01-14 22:54 斷點(diǎn) 閱讀(895) 評論(0) 編輯 收藏 所屬分類: Tomcattomcat 連接池泄露的問題
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted
轉(zhuǎn)載:
1 問題描述
Web程序在tomcat剛開始運(yùn)行時(shí)速度很快,但過一段時(shí)間后發(fā)現(xiàn)速度變得很慢。
檢查日志輸出,發(fā)現(xiàn)異常如下:
org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause:
java.util.NoSuchElementException: Timeout waiting for idle object
2 問題解決
tomcat 的數(shù)據(jù)源定義提供了三個(gè)參數(shù):
a. 如果設(shè)為true則tomcat自動(dòng)檢查恢復(fù)重新利用,沒有正常關(guān)閉的Connection.(默認(rèn)是false)
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
b. 設(shè)定連接在多少秒內(nèi)被認(rèn)為是放棄的連接,即可進(jìn)行恢復(fù)利用。
<parameter>
<name>removeAbandonedTimeout</name>
<value>60</value>
</parameter>
c. 輸出回收的日志,可以詳細(xì)打印出異常從而發(fā)現(xiàn)是在那里發(fā)生了泄漏
<parameter>
<name>logAbandoned</name>
<value>true</value>
</parameter>
posted @ 2009-02-17 16:03 斷點(diǎn) 閱讀(738) | 評論 (0)