Alex Rivera | Logout

What is the best way to 'ping' a database via JDBC?

Asked 2009-05-11T08:50:01.487
17

I'm trying to determine the best way to ping a database via JDBC. By 'best' I mean fast and low overhead. For example, I've considered executing this:

"SELECT 1 FROM DUAL"

but I believe the DUAL table is Oracle-specific, and I need something more generic.

Note that Connection has an isClosed() method, but the javadoc states that this cannot be used to test the validity of the connection.

Edit
Report

1 Answer

4

I'm not aware of a generic solution, either. For IBM's UDB on iSeries (and perhaps other DB2 systems) it would be

select 1 from SYSIBM.SYSDUMMY1;
answered 2009-05-11T09:09:06.217

Your Answer