복붙노트

[SPRING] com.mysql.jdbc.exceptions.jdbc4.CommunicationsException : 통신 링크 실패 소프트웨어로 인한 연결 중단 : recv failed [duplicate]

SPRING

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException : 통신 링크 실패 소프트웨어로 인한 연결 중단 : recv failed [duplicate]

모든. 며칠 동안이 문제가 발생했습니다. 세부 정보 스택 정보입니다.

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,940 milliseconds ago.  The last packet sent successfully to the server was 18,918 milliseconds ago.
; SQL []; 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.; nested exception is 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.
    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,940 milliseconds ago.  The last packet sent successfully to 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}, 버전 = # {버전}, freq = # {freq} 여기서 id = # {id}

그리고 서비스 코드 :

for(RelationBvo relation : list){

       Long totalCount = solrDealService.queryResult(relation.getWord(),null,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.");
}

아무도 도와 줄 수 있습니까? 대단히 감사합니다.

해결법

  1. ==============================

    1.연결 풀에서 연결을 인식하기 전에 mySQL 연결이 시간 초과됩니다. 이 문제를 해결할 수있는 방법은 여러 가지가 있습니다.

    연결 풀에서 연결을 인식하기 전에 mySQL 연결이 시간 초과됩니다. 이 문제를 해결할 수있는 방법은 여러 가지가 있습니다.

  2. from https://stackoverflow.com/questions/9527459/com-mysql-jdbc-exceptions-jdbc4-communicationsexception-communications-link-fai by cc-by-sa and MIT license