1. 程式人生 > 其它 >嚴重: testWhileIdle is true, validationQuery not set

嚴重: testWhileIdle is true, validationQuery not set

技術標籤:資料池

宣告:使用的JDK-13, MYSQL8版本資料庫,1.0.9Druid的jar包;

使用1.0.9Druid的jar包


這兩行報錯,是因為沒有SpringBoot框架xml配置,在不使用框架的情況下,如何解決

一:嚴重: testWhileIdle is true, validationQuery not set 原來properties檔案配置如下;

driverClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/logindata?serverTimezone=GMT%2B8&useSSL=false
username=root
password=186373

需要在properties配置檔案下新增一些配置;

filters=stat
initialSize=2
maxActive=300
maxWait=60000
timeBetweenEvictionRunsMillis=60000
minEvictableIdleTimeMillis=300000
validationQuery=SELECT 1
testWhileIdle=true
testOnBorrow=false
testOnReturn=false
poolPreparedStatements=false
maxPoolPreparedStatementPerConnectionSize=200

再次執行


報錯2;

資訊: {dataSource-1} inited

這是日誌資訊,沒有錯Druid採用了日誌列印機制,這不是報錯;

連線池採用了懶載入,真正用到的時候才初始化;


名詞解釋及原文https://blog.csdn.net/weixin_42323802/article/details/82726267