Checks to see if a connection looks OK. @param conn @param checkValid Whether or not to issue a isValid() check on the connection. Note: this can be expensive since it may actually issue a noop query. @return boolean @throws SQLException
(Connection conn, boolean checkValid)
| 732 | * @throws SQLException |
| 733 | */ |
| 734 | public static boolean isConnectionOK(Connection conn, boolean checkValid) throws SQLException { |
| 735 | boolean ret = conn != null && !conn.isClosed(); |
| 736 | if (checkValid) { |
| 737 | // isValid() can be expensive, so only do it if we have to and timeout after 1 second |
| 738 | ret = ret && conn.isValid(1); |
| 739 | } |
| 740 | return ret; |
| 741 | } |
| 742 | |
| 743 | /** |
| 744 | * Checks to see if a connection looks OK without issuing an isValid() check. |