public static boolean checkConnection(Connection conn){
  String sql="select now()";
  Statement stmt=null;
  ResultSet rs=null;
  try {
    stmt=conn.createStatement();
    stmt.setQueryTimeout(180);
    rs=stmt.executeQuery(sql);
    if (rs != null && rs.next())     return true;
    return false;
  }
 catch (  Exception ex) {
  }
 finally {
    close(rs);
    close(stmt);
  }
  return false;
}

public static boolean checkConnection ( Connection conn ) { String sql = "select now()" ; Statement stmt = null ; ResultSet rs = null ; try { stmt = conn . createStatement ( ) ; stmt . setQueryTimeout ( 180 ) ; rs = stmt . executeQuery ( sql ) ; if ( rs != null && rs . next ( ) ) return true ; return false ; } catch ( Exception ex ) { } finally { close ( rs ) ; close ( stmt ) ; } return false ; }
check if the given jdbc connection is still good
