简体   繁体   中英

How can I resolve the exception: discard connection

when I use druid to be my database connection pool, connecting MySQL, there is always a connection exception: discard connection.

I use: jdk8 maven3.6 MySQL56 mysql-connect-java 5.1.49 druid1.1.22

Linux

There is my log:

[ERROR] 2020-07-07 08:59:11,492 
discard connection
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during commit(). Transaction resolution unknown.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:403)
    at com.mysql.jdbc.Util.getInstance(Util.java:386)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:861)
    at com.mysql.jdbc.ConnectionImpl.commit(ConnectionImpl.java:1549)
    at com.alibaba.druid.filter.FilterChainImpl.connection_commit(FilterChainImpl.java:199)
    at com.alibaba.druid.filter.stat.StatFilter.connection_commit(StatFilter.java:267)
    at com.alibaba.druid.filter.FilterChainImpl.connection_commit(FilterChainImpl.java:194)
    at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.commit(ConnectionProxyImpl.java:122)
    at com.alibaba.druid.pool.DruidPooledConnection.commit(DruidPooledConnection.java:755)
    at com.mytest.util.mysqlDbUtils.MysqlDbUtils.executeBatch(MysqlDbUtils.java:58)
    at com.mytest.util.mysqlDbUtils.MysqlDbUtils.executeBatchNew(MysqlDbUtils.java:156)
    at com.mytest.kafkadpu.analysisData.eventData.EventDataDealUnit.dealData(EventDataDealUnit.java:72)
    at com.mytest.kafkadpu.consumerGroup.ConsumerDealDataThread.run(ConsumerDealDataThread.java:121)

And my configuration are as follows:

url=mysql connection url
username=username
password=password
filters=stat
initialSize=20
minIdle=20
maxActive=100
maxWait=60000
timeBetweenEvictionRunsMillis=63000
minEvictableIdleTimeMillis=300000
validationQuery=SELECT 1
validationQueryTimeout=100
removeAbandoned=true
removeAbandonedTimeoutMillis=60000
logAbandoned=false
testWhileIdle=true
testOnBorrow=false
testOnReturn=false
poolPreparedStatements=true
maxPoolPreparedStatementPerConnectionSize=300
defaultAutoCommit=false
keepAlive=true

I have tried to set testOnBorrow true or false, but neither of them are effective.

set

autoReconnect=true&failOverReadOnly=false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM