Druid连接Oracle数据库,连接失效导致SQL无法执行
原始配置:
type: com.alibaba.druid.pool.DruidDataSource druid: initial-size: 5 max-active: 25 min-idle: 5 max-wait: 10000 testWhileIdle: true testOnBorrow: false testOnReturn: false timeBetweenEvictionRunsMillis: 2000 minEvictableIdleTimeMillis: 600000 maxEvictableIdleTimeMillis: 900000 validationQuery: SELECT 1 FROM DUAL
修改后配置:增加keep-alive: true即可
type: com.alibaba.druid.pool.DruidDataSource druid: initial-size: 5 max-active: 25 min-idle: 5 max-wait: 10000 testWhileIdle: true testOnBorrow: false testOnReturn: false timeBetweenEvictionRunsMillis: 2000 minEvictableIdleTimeMillis: 600000 maxEvictableIdleTimeMillis: 900000 validationQuery: SELECT 1 FROM DUAL keep-alive: true
需要升级Druid版本到1.1.16之后,大于1.1.16版本,我升级到了1.1.17
https://mvnrepository.com/artifact/com.alibaba/druid-spring-boot-starter
<dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.1.17</version> </dependency>
keep-alive配置建议参考:https://github.com/alibaba/druid/wiki/DruidDataSource%E9%85%8D%E7%BD%AE