druid 1.1.21 断网后重连

cl25kdpy  于 2022-10-27  发布在  Druid
关注(0)|答案(4)|浏览(391)

网络断开后,在大概半小时左右,重新连网,获取数据库连接开始报错
com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 14111, active 0, maxActive 10, creating 1, createElapseMillis 44234, createErrorCount 5
at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1720)
at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:1402)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1382)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1372)
at DBConnectionPool.getConnection(DBConnectionPool.java:73)
at TaskDBOperation.getPlanInfo(TaskDBOperation.java:240)
at PlanManager.getAllPlan(PlanManager.java:25)
at Server$1.run(Server.java:88)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 84,547 milliseconds ago. The last packet sent successfully to the server was 44,454 milliseconds ago.
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:408)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:988)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3552)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3452)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3893)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:875)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1712)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1228)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2253)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2284)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2083)
at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:806)
at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)
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:408)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1644)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1710)
at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2753)
Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3004)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3462)
... 20 more

下面为我的配置
ds = new DruidDataSource();
ds.setDriverClassName("com.mysql.jdbc.Driver");
ds.setUrl(url);
ds.setUsername(user);
ds.setPassword(pass);
ds.setInitialSize(InitialSize); 1
ds.setMinIdle(MinIdle); 1
ds.setMaxWait(MaxWait); 1000
ds.setMaxActive(MaxActive); 10
ds.setKeepAlive(true);
ds.setTestWhileIdle(true); //开启验证连接对象有效性检测
ds.setTestOnBorrow(true);
ds.setTestOnReturn(false);
ds.setValidationQuery("SELECT 'X'");
ds.setValidationQueryTimeout(10 * 1000);
ds.setTimeBetweenEvictionRunsMillis(60 * 1000);
ds.setMinEvictableIdleTimeMillis(30 * 1000);
ds.setRemoveAbandoned(true);
ds.setRemoveAbandonedTimeout(1800);
ds.setLogAbandoned(false);
请问还需要修改或添加什么属性么

hc8w905p

hc8w905p1#

请问你解决了吗?我这边也发现断网后,即使网络重新连接上,数据库也无法自动重连。

igsr9ssn

igsr9ssn2#

我这边也出现过这个问题, 但是很难重现. 你们都能重现吗?

nwsw7zdq

nwsw7zdq4#

同出现

手动的重新创建了

相关问题