druid连接mysql

发布于 2022-01-04 04:10:48 字数 6185 浏览 896 评论 1

druid连接mysql报下面的错,但是程序还能运行,可以查询数据库

报错信息

The last packet successfully received from the server was 43,558 milliseconds ago.  The last packet sent successfully to the server was 19,193 milliseconds ago.
	at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:590) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:57) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1983) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:3773) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.alibaba.druid.pool.DruidPooledConnection.setAutoCommit(DruidPooledConnection.java:712) [druid-1.1.19.jar:1.1.19]
	at org.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler.setAutoCommit(AttributeRestoringConnectionInvocationHandler.java:98) [quartz-2.3.1.jar:?]
	at org.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler.invoke(AttributeRestoringConnectionInvocationHandler.java:66) [quartz-2.3.1.jar:?]
	at com.sun.proxy.$Proxy40.setAutoCommit(Unknown Source) [?:?]
	at org.quartz.impl.jdbcjobstore.JobStoreCMT.getNonManagedTXConnection(JobStoreCMT.java:191) [quartz-2.3.1.jar:?]
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3861) [quartz-2.3.1.jar:?]
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2802) [quartz-2.3.1.jar:?]
	at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:287) [quartz-2.3.1.jar:?]
Caused by: com.mysql.cj.core.exceptions.CJCommunicationsException: Communications link failure

The last packet successfully received from the server was 43,558 milliseconds ago.  The last packet sent successfully to the server was 19,193 milliseconds ago.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_171]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_171]
	at sun.reflect.DelegatingConstructorAccessorImpl.__newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_171]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45009) ~[?:1.8.0_171]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45012) ~[?:1.8.0_171]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_171]
	at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:54) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:93) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:133) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.core.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:149) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.mysqla.io.MysqlaProtocol.readPacket(MysqlaProtocol.java:527) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.mysqla.io.MysqlaProtocol.checkErrorPacket(MysqlaProtocol.java:723) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.mysqla.io.MysqlaProtocol.sendCommand(MysqlaProtocol.java:662) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.mysqla.io.MysqlaProtocol.sqlQueryDirect(MysqlaProtocol.java:950) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.mysqla.MysqlaSession.sqlQueryDirect(MysqlaSession.java:431) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1974) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	... 9 more
Caused by: java.net.SocketException: Software caused connection abort: recv failed
	at java.net.SocketInputStream.socketRead0(Native Method) ~[?:1.8.0_171]
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[?:1.8.0_171]
	at java.net.SocketInputStream.read(SocketInputStream.java:171) ~[?:1.8.0_171]
	at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[?:1.8.0_171]
	at com.mysql.cj.core.io.ReadAheadInputStream.fill(ReadAheadInputStream.java:101) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.core.io.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:144) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.core.io.ReadAheadInputStream.read(ReadAheadInputStream.java:174) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at java.io.FilterInputStream.read(FilterInputStream.java:133) ~[?:1.8.0_171]
	at com.mysql.cj.core.io.FullReadInputStream.readFully(FullReadInputStream.java:58) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.mysqla.io.SimplePacketReader.readHeader(SimplePacketReader.java:60) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.mysqla.io.TimeTrackingPacketReader.readHeader(TimeTrackingPacketReader.java:48) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.mysqla.io.MultiPacketReader.readHeader(MultiPacketReader.java:51) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.mysqla.io.MysqlaProtocol.readPacket(MysqlaProtocol.java:521) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.mysqla.io.MysqlaProtocol.checkErrorPacket(MysqlaProtocol.java:723) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.mysqla.io.MysqlaProtocol.sendCommand(MysqlaProtocol.java:662) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.mysqla.io.MysqlaProtocol.sqlQueryDirect(MysqlaProtocol.java:950) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.mysqla.MysqlaSession.sqlQueryDirect(MysqlaSession.java:431) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1974) ~[mysql-connector-java-6.0.6.jar:6.0.6]
	... 9 more

druid配置

<property name="maxActive" value="5" />
<property name="minIdle" value="3" />
<property name="initialSize" value="3"/>

 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风透绣罗衣 2022-01-07 14:11:18

连接池没有设置空闲检测,mysql 默认8小时会自动切断连接

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文