Closed ly576078 closed 5 years ago
有人遇到这个问题么?我这边现在也遇到这个问题了 2019-05-02 14:16:31.849 ERROR c.alibaba.druid.pool.DruidDataSource -recyle error java.sql.SQLException: Connection.clearWarnings cannot be called on a closed connection at org.mariadb.jdbc.internal.util.ExceptionMapper.getSqlException(ExceptionMapper.java:163) at org.mariadb.jdbc.MariaDbConnection.clearWarnings(MariaDbConnection.java:869) at com.alibaba.druid.pool.DruidConnectionHolder.reset(DruidConnectionHolder.java:294) at com.alibaba.druid.pool.DruidDataSource.recycle(DruidDataSource.java:1753) at com.alibaba.druid.pool.DruidPooledConnection.recycle(DruidPooledConnection.java:322) at com.alibaba.druid.pool.DruidPooledConnection.close(DruidPooledConnection.java:267)
设置testOnBorrow=true防止拿到无效连接,如果凑巧拿到无效连接,就要检查下自己的超时设置,不然会长时间挂住。如果使用长连接且有负载均衡,需要注意服务端的连接超时时间不能大于负载均衡端的超时时间。
大佬这个问题无解吗 testOnBorrow消耗性能吖
Springboot 2.0.4集成druid访问mysql数据库,服务运行过程中偶现如下错误: ERROR c.alibaba.druid.pool.DruidDataSource - recyle error java.sql.SQLException: Connection.clearWarnings cannot be called on a closed connection at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getSqlException(ExceptionMapper.java:271) at org.mariadb.jdbc.MariaDbConnection.clearWarnings(MariaDbConnection.java:1070) at com.alibaba.druid.filter.FilterChainImpl.connection_clearWarnings(FilterChainImpl.java:165) at com.alibaba.druid.filter.FilterAdapter.connection_clearWarnings(FilterAdapter.java:771) at com.alibaba.druid.filter.FilterChainImpl.connection_clearWarnings(FilterChainImpl.java:161) at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.clearWarnings(ConnectionProxyImpl.java:108) at com.alibaba.druid.pool.DruidConnectionHolder.reset(DruidConnectionHolder.java:295) at com.alibaba.druid.pool.DruidDataSource.recycle(DruidDataSource.java:1662) at com.alibaba.druid.pool.DruidPooledConnection.recycle(DruidPooledConnection.java:323) at com.alibaba.druid.filter.FilterChainImpl.dataSource_recycle(FilterChainImpl.java:4609) at com.alibaba.druid.filter.stat.StatFilter.dataSource_releaseConnection(StatFilter.java:665) at com.alibaba.druid.filter.FilterChainImpl.dataSource_recycle(FilterChainImpl.java:4605) at com.alibaba.druid.pool.DruidPooledConnection.close(DruidPooledConnection.java:266) at org.springframework.jdbc.datasource.DataSourceUtils.doCloseConnection(DataSourceUtils.java:354) at org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:341) at org.springframework.jdbc.datasource.DataSourceUtils.releaseConnection(DataSourceUtils.java:307) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:618) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:657) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:688) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:700) at org.springframework.jdbc.core.JdbcTemplate.queryForRowSet(JdbcTemplate.java:842)
druid配置如下: driver-class-name=org.mariadb.jdbc.Driver type=com.alibaba.druid.pool.DruidDataSource maxWait=180000 maxActive=20 minIdle=10 initialSize=10 timeBetweenEvictionRunsMillis=60000 minEvictableIdleTimeMillis=300000 validationQuery=select 'x' testWhileIdle=true testOnBorrow=false testOnReturn=false