• 解决异常:“The last packet sent successfully to the server was 0 milliseconds ago. ”的办法


    今天写ssm的时候遇见一个错误,

    我的报错如下

      1 警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@21ee9275 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: 
      2 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
      3 
      4 The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
      5     at sun.reflect.GeneratedConstructorAccessor23.newInstance(Unknown Source)
      6     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      7     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      8     at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
      9     at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
     10     at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:342)
     11     at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2197)
     12     at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2230)
     13     at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2025)
     14     at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:778)
     15     at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
     16     at sun.reflect.GeneratedConstructorAccessor15.newInstance(Unknown Source)
     17     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
     18     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
     19     at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
     20     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
     21     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
     22     at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
     23     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
     24     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
     25     at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
     26     at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
     27     at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
     28     at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
     29     at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
     30     at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
     31 Caused by: java.net.ConnectException: Connection refused: connect
     32     at java.net.DualStackPlainSocketImpl.connect0(Native Method)
     33     at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
     34     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
     35     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
     36     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
     37     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
     38     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
     39     at java.net.Socket.connect(Socket.java:589)
     40     at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)
     41     at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:301)
     42     ... 20 more
     43 
     44 八月 21, 2020 5:01:26 下午 com.mchange.v2.resourcepool.BasicResourcePool 
     45 警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@520d0d4e is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
     46 八月 21, 2020 5:01:26 下午 com.mchange.v2.resourcepool.BasicResourcePool 
     47 警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@634f6fcf -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: 
     48 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
     49 
     50 The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
     51     at sun.reflect.GeneratedConstructorAccessor23.newInstance(Unknown Source)
     52     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
     53     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
     54     at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
     55     at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
     56     at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:342)
     57     at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2197)
     58     at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2230)
     59     at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2025)
     60     at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:778)
     61     at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
     62     at sun.reflect.GeneratedConstructorAccessor15.newInstance(Unknown Source)
     63     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
     64     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
     65     at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
     66     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
     67     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
     68     at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
     69     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
     70     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
     71     at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
     72     at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
     73     at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
     74     at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
     75     at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
     76     at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
     77 Caused by: java.net.ConnectException: Connection refused: connect
     78     at java.net.DualStackPlainSocketImpl.connect0(Native Method)
     79     at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
     80     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
     81     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
     82     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
     83     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
     84     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
     85     at java.net.Socket.connect(Socket.java:589)
     86     at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)
     87     at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:301)
     88     ... 20 more
     89 
     90 八月 21, 2020 5:01:26 下午 com.mchange.v2.resourcepool.BasicResourcePool 
     91 警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@6c971fde -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: 
     92 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
     93 
     94 The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
     95     at sun.reflect.GeneratedConstructorAccessor23.newInstance(Unknown Source)
     96     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
     97     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
     98     at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
     99     at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
    100     at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:342)
    101     at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2197)
    102     at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2230)
    103     at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2025)
    104     at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:778)
    105     at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    106     at sun.reflect.GeneratedConstructorAccessor15.newInstance(Unknown Source)
    107     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    108     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    109     at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    110     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
    111     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
    112     at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
    113     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
    114     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
    115     at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
    116     at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
    117     at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
    118     at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
    119     at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
    120     at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
    121 Caused by: java.net.ConnectException: Connection refused: connect
    122     at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    123     at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    124     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    125     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    126     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    127     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    128     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    129     at java.net.Socket.connect(Socket.java:589)
    130     at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)
    131     at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:301)
    132     ... 20 more

    上网查了很多,

    有的说是dao层xml条件参数值错误,仔细检查并没有,

    有的说是一般有Illegal access: this web application instance has been stopped already.  Could not load+....+The eventual following stack trace is caused by+.......这种类型的错误都是因为重新加载失败引起的;

    检查各种属性名和参数名都没问题之后,最后打开服务才发现是mysql服务停止,打开就好,其实解决之后发现,报错的提示中含有jdbc几个关键字,不难发现是连接出现错误

    希望能给朋友们解决问题

    总结,遇到bug不要急,先排除代码问题再看配置,再康康环境,慢慢来,冰冻三尺,非一日之寒

    要看日出必须守到拂晓。
  • 相关阅读:
    Spring Boot学习——AOP编程的简单实现
    Spring Boot学习——表单验证
    Spring Boot学习——数据库操作及事务管理
    Spring Boot学习——Controller的使用
    Spring Boot学习——Spring Boot配置文件application
    Spring Boot学习——第一个Spring Boot程序
    Spring Boot学习——Spring Boot简介
    activeMQ队列模式和主题模式的Java实现
    Markdown语法格式
    Java基础知识系列——Exception
  • 原文地址:https://www.cnblogs.com/sunlang369/p/13542099.html
Copyright © 2020-2023  润新知