Keep-Alive query in HSQLDB

Today I was in the need for a good keep-alive statement that works with HSQLDB. For all the code running against MySQL we usually use:


but the statement is incompatible with HSQLDB. The problem came up in one of our unit-tests, where we often use a in-memory database instead of depending on a externally running MySQL instance.

For me, a good keep-alive statement is one, that is not depending on a user defined schema and table structure. I came up with this one for HSQLDB:


which should work in every vanilla HSQLDB installation. I haven't looked thoroughly into right and permission handling but I kind of assume that every user can at least read from this schema. If you run HSQLDB in memory, you are most likely using the sa user anyways.

In our case it is semi-useful, to programmatically verify that the in-memory database is up during unit-tests. It will make more sense in production code against MySQL. You should also be able to use this as the validationQuery in a org.apache.commons.dbcp.BasicDataSource or as keep-alive statement for Quartz.