/** * Fires a new connection event on all listeners. * * @param closed <code>true</code> if <code>close</code> has been called on the connection; <code> * false</code> if the <code>sqlException</code> represents an error where the connection may * not longer be used. * @param sqlException the SQLException to pass to the listeners */ public synchronized void fireConnectionEvent(boolean closed, SQLException sqlException) { if (listeners.size() > 0) { ConnectionEvent connectionEvent = new ConnectionEvent(this, sqlException); Iterator iterator = listeners.iterator(); while (iterator.hasNext()) { ConnectionEventListener listener = (ConnectionEventListener) iterator.next(); if (closed) { listener.connectionClosed(connectionEvent); } else { try { if (connection == null || connection.isClosed()) { listener.connectionErrorOccurred(connectionEvent); } } catch (SQLException ex) { // Will never occur } } } } }
/** * Closes the database connection. * * @throws SQLException if an error occurs */ public synchronized void close() throws SQLException { connection.close(); connection = null; // Garbage collect the connection }
/** * Closes the database connection. * * @throws SQLException if an error occurs */ public synchronized void close() throws SQLException { _connection.close(); _connection = null; // Garbage collect the connection fireConnectionEvent(false, null); }