title: Efficient SQL test query or validation query that will work across all (or most) databases
body: <p>Many database connection pooling libraries provide the ability to test their SQL connections for idleness. For example, the JDBC pooling library <a href="http://www.mchange.com/projects/c3p0/index.html" rel="noreferrer">c3p0</a> has a property called <a href="http://www.mchange.com/projects/c3p0/index.html#preferredTestQuery" rel="noreferrer"><code>preferredTestQuery</code></a>, which gets executed on the connection at configured intervals. Similarly, Apache Commons DBCP has <a href="https://commons.apache.org/proper/commons-dbcp/api-1.4/org/apache/commons/dbcp/BasicDataSource.html" rel="noreferrer"><code>validationQuery</code></a>.</p>
  <p>Many <a href="https://forum.hibernate.org/viewtopic.php?t=943079&amp;highlight=c3p0+connection+timeout" rel="noreferrer">example</a> <a href="http://forums.mysql.com/read.php?39,139821,160175" rel="noreferrer">queries</a> I've seen are for MySQL and recommend using <code>SELECT 1;</code> as the value for the test query. However, this query doesn't work on some databases (e.g. HSQLDB, for which <code>SELECT 1</code> expects a <code>FROM</code> clause).</p>
  <p>Is there a database-agnostic query that's equivalently efficient but will work for all SQL databases?</p>
  <p><strong>Edit:</strong></p>
  <p>If there's not (which seems to be the case), can somebody suggest a set of SQL queries that will work for various database providers? My intention would be to programmatically determine a statement I can use based on my database provider configuration.</p>