DBCP – validationQuery for different Databases

There is not only one validationQuery for all databases. On each database you have to use different validationQuery.

After few hours of googling and testing I have collected this table:

Database validationQuery notes

  • hsqldbselect 1 from INFORMATION_SCHEMA.SYSTEM_USERS
  • Oracleselect 1 from dual
  • DB2select 1 from sysibm.sysdummy1
  • mysqlselect 1
  • microsoft SQL Serverselect 1 (tested on SQL-Server 9.0, 10.5 [2008])
  • postgresqlselect 1
  • ingresselect 1
  • derbyvalues 1
  • H2select 1
  • Firebirdselect 1 from rdb$database
  • MariaDbselect 1
  • Informixselect 1 from systables
  • Hiveselect 1
  • Impalaselect 1

I wrote about it on my blog – validation query for various databases.

In advance there is an example of class, which return validationQuery according to JDBC driver.

Or does anybody have better solution?

Leave a Comment