Thread: JDBC: connection.isClosed() doesnt throw exception
andre levy (andre@freever.com) reports a bug with a severity of 2 The lower the number the more severe it is. Short Description JDBC: connection.isClosed() doesnt throw exception Long Description connection.isClosed() doesn't throw an SQLException if "a database access error occurs". (cf http://java.sun.com/j2se/1.3/docs/api/java/sql/Connection.html#isClosed()) this means that if connection to db is closed, or worse, if db is down, I can't know it until I actually try to send a request! Sample Code This piece of code helps me to recover from a db restart without restarting my service... private Statement getStatement() throws SQLException { Statement stmt = null; try { boolean closed = m_connection.isClosed(); if (closed) openDb(); } catch(SQLException e) { closeDb(); openDb(); } stmt = m_connection.createStatement(); return stmt; } // getStatement No file was uploaded with this report