当前位置: 代码迷 >> 综合 >> com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Too many connections
  详细解决方案

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Too many connections

热度:68   发布时间:2023-11-19 22:02:11.0

项目2分钟更新一次井下人员状况(查询数据库人员)

大概10分钟以后就会出现异常!

之前因为这些内容是显示在LED大屏上的,后来上去查看大屏显示异常,一位是局域网掉线的原因;

今天才发现是程序不够完善

但是我明明关闭连接了啊,怎么还是too many connections???

错误信息如下:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Too many connectionsat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:525)at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)at com.mysql.jdbc.Util.getInstance(Util.java:381)at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3536)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3468)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:917)at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3974)at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1282)at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2142)at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:773)at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)at sun.reflect.GeneratedConstructorAccessor12.newInstance(Unknown Source)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:525)at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37)at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1188)at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95)at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)at cn.com.jdbc.JdbcUtils_DBCP.getConnection(JdbcUtils_DBCP.java:48)at cn.com.servlet.Inform_LED.doPost(Inform_LED.java:91)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)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 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)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:169)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:722)
地表共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-130m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>斜井共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-240m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-290m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-340m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-400m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br>
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Too many connectionsat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:525)at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)at com.mysql.jdbc.Util.getInstance(Util.java:381)at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3536)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3468)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:917)at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3974)at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1282)at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2142)at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:773)at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)at sun.reflect.GeneratedConstructorAccessor12.newInstance(Unknown Source)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:525)at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37)at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1188)at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95)at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)at cn.com.jdbc.JdbcUtils_DBCP.getConnection(JdbcUtils_DBCP.java:48)at cn.com.servlet.Inform_LED.doPost(Inform_LED.java:91)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)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 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)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:169)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:722)
地表共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-130m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>斜井共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-240m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-290m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-340m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-400m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br>
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Too many connectionsat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:525)at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)at com.mysql.jdbc.Util.getInstance(Util.java:381)at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3536)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3468)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:917)at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3974)at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1282)at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2142)at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:773)at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)at sun.reflect.GeneratedConstructorAccessor12.newInstance(Unknown Source)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:525)at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37)at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1188)at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95)at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)at cn.com.jdbc.JdbcUtils_DBCP.getConnection(JdbcUtils_DBCP.java:48)at cn.com.servlet.Inform_LED.doPost(Inform_LED.java:91)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)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 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)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:169)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:722)
地表共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-130m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>斜井共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-240m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-290m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-340m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-400m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br>

 然后我设置了mysql等待时间,时间越短的话,等待连接越少;

 

虽然不报上面的错误,但是又出现了下面的错误

org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhaustedat org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:103)at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)at cn.com.jdbc.JdbcUtils_DBCP.getConnection(JdbcUtils_DBCP.java:48)at cn.com.servlet.Inform_LED.doPost(Inform_LED.java:114)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)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 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)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:169)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:722)
Caused by: java.util.NoSuchElementException: Timeout waiting for idle objectat org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1174)at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95)... 25 more
java.sql.SQLException: Connection is closed.at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.checkOpen(PoolingDataSource.java:174)at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:179)at cn.com.jdbc.JdbcUtils_DBCP.release(JdbcUtils_DBCP.java:81)at cn.com.servlet.Inform_LED.doPost(Inform_LED.java:244)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)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 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)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:169)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:722)
java.sql.SQLException: Connection is closed.at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.checkOpen(PoolingDataSource.java:174)at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:179)at cn.com.jdbc.JdbcUtils_DBCP.release(JdbcUtils_DBCP.java:81)at cn.com.servlet.Inform_LED.doPost(Inform_LED.java:245)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)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 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)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:169)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:722)
地表共有3人 <br>    公司:    徐帮胜    何传贵<br>    中矿:<br>    新龙:<br>    陈方生<br>-130m共有2人 <br>    公司:    王荣丰    郑永杰<br>    中矿:<br>    新龙:<br><br>斜井共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-240m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-290m共有1人 <br>    公司:    吴成贵<br>    中矿:<br>    新龙:<br><br>-340m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-400m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br>
org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhaustedat org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:103)at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)at cn.com.jdbc.JdbcUtils_DBCP.getConnection(JdbcUtils_DBCP.java:48)at cn.com.servlet.Inform_LED.doPost(Inform_LED.java:89)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)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 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)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:169)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:722)
Caused by: java.util.NoSuchElementException: Timeout waiting for idle objectat org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1174)at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95)... 25 more
java.sql.SQLException: Connection is closed.at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.checkOpen(PoolingDataSource.java:174)at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:179)at cn.com.jdbc.JdbcUtils_DBCP.release(JdbcUtils_DBCP.java:81)at cn.com.servlet.Inform_LED.doPost(Inform_LED.java:244)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)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 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)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:169)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:722)
java.sql.SQLException: Connection is closed.at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.checkOpen(PoolingDataSource.java:174)at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:179)at cn.com.jdbc.JdbcUtils_DBCP.release(JdbcUtils_DBCP.java:81)at cn.com.servlet.Inform_LED.doPost(Inform_LED.java:245)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)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 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)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:169)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:722)
地表共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-130m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>斜井共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-240m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-290m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-340m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br><br>-400m共有0人 <br>    公司:<br>    中矿:<br>    新龙:<br>

这几天这个问题一直困扰着我,解决方案如下:

1.程序涉及几个conn,st,rs的,一定要分开,尽可能的分开了,几个conn就用几个try{

}catch{

}finally{

关闭连接

}

我之前虽然都关闭连接了,但是3个conn,st,rs写在一个try{}cath(){}finally{关闭三个连接}

总结:

出现这些问题:

不要重启服务器,这个没用的,虽然重启之后正常了,但是没多久又不行,因为是程序问题

一定一定一定一定一定一定一定一定检查程序,关闭连接,关闭连接

多个conn,rs st的一定要分开了,结果集用集合装起来,不要如下:

多个rs放在一起如果出错就会导致其中一个连接无法收回,一直处于阻塞

try{

while(rs.next){

num = rs.getString(1);
                        // 对每个编号进行最近时间的查询基站
                        conn1 = JdbcUtils_DBCP.getConnection();
                        String sqls = "SELECT * FROM yh WHERE number='" + num + "' ORDER BY TIME DESC LIMIT 1";
                        st1 = conn1.prepareStatement(sqls);
                        rs1 = st1.executeQuery();
                        if (rs1.next()) {
                            times = rs1.getString(8);//这个是时间
                            // 判断最后一条记录的时间跟当前时间的距离
                            // 获取当前的时间
                                Date date = new Date();

.........................................

}

}catch(){

}finally{

关闭连接

}

 

  相关解决方案