validationQuery是用来验证数据库连接的查询语句,这个查询语句必须是至少返回一条结果的SELECT语句。每种数据库都有各自的验证语句,下表中从网上收集了几种常见数据库的validationQuery。

数据库validationQuery
Oracleselect 1 from dual
MySQLselect 1
Microsoft SQL Serverselect 1
DB2select 1 from sysibm.sysdummy1
SQLiteselect 1
HSQLDBselect 1 from INFORMATION_SCHEMA.SYSTEM_USERS
postgresqlselect version()
ingresselect 1
Apache Derbyselect 1
H2select 1
Informixselect count(*) from systables

更多推荐