java-com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败软件导致连接中止:recv失败

前端之家收集整理的这篇文章主要介绍了java-com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败软件导致连接中止:recv失败 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

这个问题已经在这里有了答案:            >            Official reasons for “Software caused connection abort: socket write error”                                    13个
所有.
我已经遇到了几天的问题,这是详细信息堆栈信息:

org.springframework.dao.RecoverableDataAccessException: 
### Error updating database.  Cause: com.MysqL.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 18,940 milliseconds ago.  The last packet sent successfully to the server was 18,918 milliseconds ago.
### The error may involve com.tuan800.searchtask.model.dao.mybatis.RelationDao.updateSuggest-Inline
### The error occurred while setting parameters
### Cause: com.MysqL.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 18,918 milliseconds ago.
; sql []; Communications link failure

The last packet successfully received from the server was 18,918 milliseconds ago.; nested exception is com.MysqL.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 18,918 milliseconds ago.
    at org.springframework.jdbc.support.sqlExceptionSubclassTranslator.doTranslate(sqlExceptionSubclassTranslator.java:98)
    at org.springframework.jdbc.support.AbstractFallbacksqlExceptionTranslator.translate(AbstractFallbacksqlExceptionTranslator.java:72)
    at org.springframework.jdbc.support.AbstractFallbacksqlExceptionTranslator.translate(AbstractFallbacksqlExceptionTranslator.java:80)
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
    at org.mybatis.spring.sqlSessionTemplate$sqlSessionInterceptor.invoke(sqlSessionTemplate.java:346)
    at $Proxy10.update(Unknown Source)
    at org.mybatis.spring.sqlSessionTemplate.update(sqlSessionTemplate.java:245)
    at com.tuan800.searchtask.model.dao.mybatis.impl.RelationDaoImpl.updateSuggest(RelationDaoImpl.java:24)
    at com.tuan800.searchtask.service.impl.RelationServiceImpl.modifyRelationCount(RelationServiceImpl.java:64)
    at com.tuan800.searchtask.RelationIndexTask.main(RelationIndexTask.java:33)
    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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
Caused by: com.MysqL.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 18,918 milliseconds ago.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    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:409)
    at com.MysqL.jdbc.sqlError.createCommunicationsException(sqlError.java:1118)
    at com.MysqL.jdbc.MysqLIO.reuseAndReadPacket(MysqLIO.java:3055)
    at com.MysqL.jdbc.MysqLIO.reuseAndReadPacket(MysqLIO.java:2941)
    at com.MysqL.jdbc.MysqLIO.checkErrorPacket(MysqLIO.java:3489)
    at com.MysqL.jdbc.MysqLIO.sendCommand(MysqLIO.java:1959)
    at com.MysqL.jdbc.MysqLIO.sqlQueryDirect(MysqLIO.java:2113)
    at com.MysqL.jdbc.ConnectionImpl.execsql(ConnectionImpl.java:2568)
    at com.MysqL.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2113)
    at com.MysqL.jdbc.PreparedStatement.execute(PreparedStatement.java:1364)
    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:989)
    at sun.reflect.GeneratedMethodAccessor163.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:45)
    at $Proxy20.execute(Unknown Source)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:22)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:51)
    at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:29)
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:88)
    at org.apache.ibatis.session.defaults.DefaultsqlSession.update(DefaultsqlSession.java:121)
    at sun.reflect.GeneratedMethodAccessor165.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.mybatis.spring.sqlSessionTemplate$sqlSessionInterceptor.invoke(sqlSessionTemplate.java:338)
    ... 10 more
Caused by: java.net.SocketException: Software caused connection abort: recv Failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at com.MysqL.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)
    at com.MysqL.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)
    at com.MysqL.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)
    at com.MysqL.jdbc.MysqLIO.readFully(MysqLIO.java:2499)
    at com.MysqL.jdbc.MysqLIO.reuseAndReadPacket(MysqLIO.java:2952)
    ... 32 more

我想通过mybatis和spring更新MysqL中的一条记录,并一一更新,下面是mybatis config:

      更新建议集count =#{count},version =#{version},freq =#{freq},其中id =#{id}
 

以及服务代码

for(RelationBvo relation : list){

       Long totalCount = solrDealService.queryResult(relation.getWord(),null,0);

       relation.setCount(totalCount.intValue());

       if(relation.getFreq() == 0){
            relation.setFreq(1);
       }

       ***relationDao.updateSuggest(relation);//update record***

       executedCount++;

       logger.info("Program have executed "+executedCount+" records.");
}

有人可以帮我吗?非常感谢.

最佳答案
您的MysqL连接在连接池识别它们之前已超时.有多种解决方法

>增加MysqL配置文件(my.ini)中的超时值
>减少连接池中的空闲时间,以便在MysqL关闭连接之前将其丢弃
>在您的池配置中添加一个验证连接查询,以便该池在将每个连接提供给您之前先对其进行测试,但这会严重降低系统速度.

原文链接:https://www.f2er.com/spring/531785.html

猜你在找的Spring相关文章