public void sessionDestroyed(HttpSessionEvent hse) { Database db = null; Statement stmt = null; try { db = new Database(); db.connect(); stmt = db.getStatement(); stmt.executeUpdate( "update ext_sessions set closed = 1 where id = '" + hse.getSession().getId() + "'"); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (stmt != null) stmt.close(); } catch (SQLException e) { } stmt = null; if (db != null) db.disconnect(); } }