当前位置: 代码迷 >> Java Web开发 >> 关于 Communications link failure 的解决解决方法
  详细解决方案

关于 Communications link failure 的解决解决方法

热度:1152   发布时间:2016-04-17 11:06:37.0
关于 Communications link failure 的解决

这个项目是基于SSH 框架,数据库是MYSQL ,服务器是TOMCAT,部署完成后,经过一段时间(估计约8小时,但不确定),当再次访问该项目,即:当与数据库再次连接时,就报下面这个异常,请各位帮忙分析解决,高分酬谢!

Java code
23:02:28,445 ERROR JDBCTransaction:67 - JDBC begin failedcom.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureLast packet sent to the server was 31 ms ago.    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)    at java.lang.reflect.Constructor.newInstance(Unknown Source)    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3009)    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2895)    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3438)    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2548)    at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4916)    at org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)    at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)    at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:63)    at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)    at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:510)    at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:350)    at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:262)    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)    at $Proxy26.findUserByUserNameAndPassword(Unknown Source)    at com.lenovo.mfgot.action.login.LoginAction.execute(LoginAction.java:56)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)    at java.lang.reflect.Method.invoke(Unknown Source)    at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)    at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)


applicationContext_common.xml 部分如下:
XML code
..........省略部分........    <bean id="dataSource"        class="org.apache.commons.dbcp.BasicDataSource"        destroy-method="close">        <property name="driverClassName"            value="com.mysql.jdbc.Driver">        </property>        <property name="url"            value="jdbc:mysql://localhost:3306/mfgotv2">        </property>        <property name="username" value="root"></property>        <property name="password" value="javaweb2.0"></property>        <property name="maxActive" value="100"></property>        <property name="maxIdle" value="30"></property>        <property name="maxWait" value="-1"></property>        <property name="defaultAutoCommit" value="true"></property>    </bean>..........省略部分........
  相关解决方案