Esempio n. 1
0
 /**
  * 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);
   }
 }
Esempio n. 2
0
 /** INTERNAL. Called after executing a command that could have written something. */
 protected void afterWriting() {
   session.afterWriting();
 }