启动Tomcat时,发生如下异常:

 DEBUG resourcepool.BasicResourcePool  - An exception occurred while acquiring a poolable resource. Will retry. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.  at 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:411)  at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1129)  at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:358)  at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2489)  at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2526)  at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2311)  at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)  at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)  at 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:411)  at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)  at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:347)  at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)  at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)  at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)  at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)  at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)  at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)  at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)  at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) Caused by: java.net.ConnectException: Connection refused: connect  at java.net.DualStackPlainSocketImpl.connect0(Native Method)  at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)  at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)  at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)  at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)  at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)  at java.net.Socket.connect(Socket.java:579)  at java.net.Socket.connect(Socket.java:528)  at java.net.Socket.<init>(Socket.java:425)  at java.net.Socket.<init>(Socket.java:241)  at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)  at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:308)  ... 20 more

 

异常截图:

 

最终找到原因:

  因为是一开机就直接启动项目,忘记打开数据库服务,所以报了ConnectionException,打开数据库服务马上就好使了。

 

posted on 2016-01-19 23:27  穆离  阅读(1317)  评论(0编辑  收藏  举报