@Override
   public void close() throws SQLException {

      switch(transactionState) {
         case CLOSED: //Segment close will ignore multiple close on same connection, but need to skip the other stuff.
            return;
         case NONE: //Autocommit never changed
            transactionState = TransactionState.CLOSED;
            break;
         default:
            try {
               resolveIncompleteTransactions();
               transactionState = TransactionState.CLOSED;
            } catch(Throwable t) {
               setLogicalCloseException(t);
            } finally {
               try {
                  if(!conn.getAutoCommit()) { //Set auto-commit
                     conn.setAutoCommit(true);
                  }
               } catch(Throwable t) {
                  setLogicalCloseException(t);
               }
            }
      }

      boolean openStatements = closeStatements();

      Throwable logicalCloseException = this.logicalCloseException; //Preserve the exception - segment will set to null. 

      segment.close(this);

      if(logicalCloseException != null) { //Now throw to the caller
         Util.throwException(logicalCloseException);
      }

      if(openStatements && openStatementPolicy == OpenStatementPolicy.REPORT) {
         throw new SQLException("Connection has open statements", JDBConnection.SQLSTATE_CONNECTION_EXCEPTION);
      }
   }
@ Override public void close ( ) throws SQLException { switch ( transactionState ) { case CLOSED : return ; case NONE : transactionState = TransactionState . CLOSED ; break ; default : try { resolveIncompleteTransactions ( ) ; transactionState = TransactionState . CLOSED ; } catch ( Throwable t ) { setLogicalCloseException ( t ) ; } finally { try { if ( ! conn . getAutoCommit ( ) ) { conn . setAutoCommit ( true ) ; } } catch ( Throwable t ) { setLogicalCloseException ( t ) ; } } } boolean openStatements = closeStatements ( ) ; Throwable logicalCloseException = this . logicalCloseException ; segment . close ( this ) ; if ( logicalCloseException != null ) { Util . throwException ( logicalCloseException ) ; } if ( openStatements && openStatementPolicy == OpenStatementPolicy . REPORT ) { throw new SQLException ( "Connection has open statements" , JDBConnection . SQLSTATE_CONNECTION_EXCEPTION ) ; } }
Returns this connection to the segment without change to the real connection.
<p>
Ignores close after the first.
</p>