运行一段时间出现Cannot get a connection, pool exhausted

]-[JDBCExceptionReporter:234] Cannot get a connection, pool exhausted

at sun.reflect.GeneratedMethodAccessor588.invoke(Unknown Source)2019-07-31 16:16:20,349 ERROR [listenerContainer_ryyj-436]-[JDBCExceptionReporter:234] Cannot get a connection, pool exhausted

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at hong.javanet.web.Page.execute(Page.java:436)
at hong.javanet.web.PageAction.execute(PageAction.java:87)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
2019-07-31 16:16:20,349 ERROR [listenerContainer_ryyj-431]-[JDBCExceptionReporter:234] Cannot get a connection, pool exhausted
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.dragonsoft.component.logging.web.LogAuditEnvInitializeFilter.doFilter(LogAuditEnvInitializeFilter.java:83)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)2019-07-31 16:16:20,349 ERROR [listenerContainer_ryyj-433]-[JDBCExceptionReporter:234] Cannot get a connection, pool exhausted

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.dragonsoft.common.core.security.licence.LicensesFilter.doFilter(LicensesFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)2019-07-31 16:16:20,349 ERROR [listenerContainer_ryyj-434]-[JDBCExceptionReporter:234] Cannot get a connection, pool exhausted

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.dragonsoft.common.core.web.filter.NoCachingFilter.doFilter(NoCachingFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.dragonsoft.common.core.web.filter.LoginFilter.doFilter(LoginFilter.java:100)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at edu.yale.its.tp.cas.client.filter.CASFilter.doFilter(CASFilter.java:445)
at com.dragonsoft.common.sys.dids.DidsFilter.doFilter(DidsFilter.java:58)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
2019-07-31 16:16:20,349 ERROR [listenerContainer_ryyj-437]-[JDBCExceptionReporter:234] Cannot get a connection, pool exhausted
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.dragonsoft.common.core.web.filter.EncodingFilter.doFilter(EncodingFilter.java:78)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:230)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)2019-07-31 16:16:20,350 ERROR [listenerContainer_ryyj-432]-[JDBCExceptionReporter:234] Cannot get a connection, pool exhausted

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)2019-07-31 16:16:20,350 ERROR [listenerContainer_ryyj-434]-[JDBCExceptionReporter:234] Cannot get a connection, pool exhausted

常规解决思路【摘录】:
tomcat 的数据源定义提供了三个参数:
a. 如果设为true则tomcat自动检查恢复重新利用,没有正常关闭的Connection.(默认是false)

< name>removeAbandoned
< value>true
< /parameter>
b. 设定连接在多少秒内被认为是放弃的连接,即可进行恢复利用。

< name>removeAbandonedTimeout
< value>60
< /parameter>
c. 输出回收的日志,可以详细打印出异常从而发现是在那里发生了泄漏

< name>logAbandoned
< value>true
< /parameter>

除了网上【上面】常说的解决办法外,还需要注意这一点,部分研发人员会把连接池设置放到数据库中,如果遇到这种就需要排错工程师对业务系统架构熟悉,才会清楚如何修改。

本例中就是在数据库 的数据源参数连接填写数据库的IP地址实例名用户名密码等连接信息,但是连接池设置非常小,业务量一旦上来就会出现上面的错误。

你可能感兴趣的:(TOMCAT)