报错信息:
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)
问题:
spring.datasource.druid.initial-size=1
spring.datasource.druid.min-idle=1
spring.datasource.druid.max-active=20
spring.datasource.druid.test-on-borrow=true
spring.datasource.druid.stat-view-servlet.allow=true
spring.datasource.druid.max-wait=60000
解决方案:
spring.datasource.druid.initial-size=1
spring.datasource.druid.min-idle=1
spring.datasource.druid.max-active=20
spring.datasource.druid.test-on-borrow=false
spring.datasource.druid.test-while-idle=true
spring.datasource.druid.validation-query=select 'X'
因为少配置了这个所以拿到了连接不检查,哭晕......... 怪自己太年轻......
spring.datasource.druid.validation-query=select 'X'