com.alibaba.druid.pool.DruidDataSource error : testOnBorrow is true, validationQuery not set
针对以上遇见的问题自我做个记录,以防出现类似问题遗忘
1、在DB的参数配置文件上加
validationQuery:SELECT 1
testWhileIdle:true
testOnBorrow:false
testOnReturn:false
2、在连接DB的配置文件上加
<util:properties id="ojdbc" location="classpath:config.properties" />
<property name="validationQuery" value="#{ojdbc.validationQuery}" />
<property name="testWhileIdle" value="#{ojdbc.testWhileIdle}" />
<property name="testOnBorrow" value="#{ojdbc.testOnBorrow}" />
<property name="testOnReturn" value="#{ojdbc.testOnReturn}" />
DBCP针对不同DB的validationQuery
oracle:select 1 from dual
mysql:select 1
derby:values 1
DB2:select 1 from sysibm.sysdummy1
内容仅供参考