• jdbc启动错误(The driver has not received any packets from the server)


    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.GeneratedConstructorAccessor15.newInstance(Unknown Source)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
    	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
    	at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:690)
    	at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1093)
    	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2338)
    	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371)
    	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)
    	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
    	at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    	at sun.reflect.GeneratedConstructorAccessor16.newInstance(Unknown Source)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
    	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
    	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
    	at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)
    	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.ThreadPerTaskAsynchronousRunner$TaskThread.run(ThreadPerTaskAsynchronousRunner.java:255)
    Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
    	at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2539)
    	at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:614)
    	... 20 more
    2012-04-20 10:17:57,976-[HL] WARN Task-Thread-for-com.mchange.v2.async.ThreadPerTaskAsynchronousRunner@3729f7 com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1e88181 -- 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: 
      com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
    

      原因大概就是启动的时候发送了一些测试语句到mysql,但是没有得到响应,估计是连接超时的问题

      java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
    	at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
    	at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:65)
    	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:527)
    	at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
    	at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)
    	at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:111)
    	at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
    	at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
    	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:855)
    	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:774)
    	at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:540)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    	at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    	at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    Caused by: com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@192c07a -- timeout at awaitAvailable()
    	at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1317)
    	at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
    	at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
    	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
    	... 38 more
    

      这个东西以前没有注意到,上网找来了很多的解决方法

    最好的如下:

    jdbc.url=jdbc:mysql://localhost:3306/totosea?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&failOverReadOnly=false
    

      在mysql的安装目录下找到my.ini

    添加

    wait_timeout=31536000
    interactive_timeout=31536000
    

      

  • 相关阅读:
    elinput校验利率输入框
    Schema 和 Universal Link
    Oracle数据库恢复删除数据的方法
    element ui 获取table行索引
    愿有人陪你颠沛流离
    古诗词中爱情的模样
    在细雨中呐喊
    麦田里的守望者
    我打碎了夕阳
    工作笔记
  • 原文地址:https://www.cnblogs.com/tatame/p/2458907.html
Copyright © 2020-2023  润新知