Ну примерно так и есть
Код:
boolean verifyConnection() {
Connection conn = null;
try {
conn = DriverManager.getConnection(...);
//conn.getMetaData();
return true;
} catch(SQLException e) {
return false;
} finally {
if (conn != null) try { conn.close(); } catch(Exception ignored) {}
}
}