Connection conn = null;
Statement stmt = null;
ResultSet rset = null; try {
conn = dataSource.getConnection();
stmt = conn.createStatement();
rset = stmt.executeQuery("select 1 from dual");
} catch (SQLException e) {
e.printStackTrace();
} finally {
try { if (rset != null) rset.close(); } catch(Exception e) { }
try { if (stmt != null) stmt.close(); } catch(Exception e) { }
try { if (conn != null) conn.close(); } catch(Exception e) { }
}