/** * Closes this connection. All open statements, prepared statements and result sets that where * created by this connection become invalid after calling this method. If there is an uncommitted * transaction, it will be rolled back. */ public synchronized void close() throws SQLException { try { debugCodeCall("close"); openStackTrace = null; if (executingStatement != null) { executingStatement.cancel(); } if (session == null) { return; } session.cancel(); try { synchronized (session) { if (!session.isClosed()) { try { // roll back unless that would require to re-connect // (the transaction can't be rolled back after re-connecting) if (!session.isReconnectNeeded(true)) { rollbackInternal(); session.afterWriting(); } closePreparedCommands(); } finally { session.close(); } } } } finally { session = null; } } catch (Exception e) { throw logAndConvert(e); } }
/** * Rolls back the current transaction. This call has only an effect if auto commit is switched * off. * * @throws SQLException if the connection is closed */ public synchronized void rollback() throws SQLException { try { debugCodeCall("rollback"); checkClosedForWrite(); try { rollbackInternal(); } finally { afterWriting(); } } catch (Exception e) { throw logAndConvert(e); } }