docs: private void cleanupTransactions(boolean inCleanup) throws ResourceException 
      {
          final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
  
          //Send connection error event if in transtates: Global transaction, Local Transaction,
          // or Trans ending because cleanup should never be called from these states.  If it is,
          // we rollback and throw the exception
  
          switch (stateMgr.transtate) {
  
              case WSStateManager.GLOBAL_TRANSACTION_ACTIVE: {
                  try {
                      ((WSRdbXaResourceImpl) xares).end();
                  } catch (javax.transaction.xa.XAException xae) {
                      // No FFDC code needed; this is a normal case.
                      // Continue with the rollback if an exception is thrown on end. 
                  }
                  
                  if (aborted) {
                      break;
                  }
  
                  try {
                      ((WSRdbXaResourceImpl) xares).rollback();
                  } catch (javax.transaction.xa.XAException xae) {
                      FFDCFilter.processException(xae, "com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions", "1200", this);
  
                      if (isTraceOn && tc.isEventEnabled())
                          Tr.event(this, tc, 
                                   "Failed to end or rollback XAResource during cleanup from failure " +
                                                   "state. Continuing with cleanup.",
                                   AdapterUtil.getXAExceptionCodeString(xae.errorCode));
  
                      throw new DataStoreAdapterException("DSA_ERROR", xae, getClass());
                  }
  
                  if (inCleanup && !aborted) 
                  {
                      String message =
                                      "Cannot call 'cleanup' on a ManagedConnection while it is still in a " +
                                                      "transaction.";
  
                      ResourceException resX = new DataStoreAdapterException("DSA_ERROR", null, getClass(), message);
  
                      // Use FFDC to log the possible components list. 
                      FFDCFilter.processException(resX,
                                                  "com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions",
                                                  "1562", this, new Object[] { message, " Possible components: Connection Manager, Transactions" });
  
                      throw resX;
                  }
                  break; 
              }
  
              case WSStateManager.LOCAL_TRANSACTION_ACTIVE:
              case WSStateManager.TRANSACTION_ENDING:
              {
                  // If no work was done during the transaction, the autoCommit value may still
                  // be on.  In this case, just no-op, since some drivers like ConnectJDBC 3.1
                  // don't allow commit/rollback when autoCommit is on.  
  
                  if (aborted) {
                      break;
                  }
                  
                  if (!currentAutoCommit)
                      try { // autoCommit is off
                          sqlConn.rollback();
                      } catch (SQLException se) {
                          FFDCFilter.processException(se, "com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions", "1223", this);
  
                          if (isTraceOn && tc.isEventEnabled())
                              Tr.event(this, tc, 
                                       "Connection rollback failed. Continuing with cleanup.");
  
                          throw new DataStoreAdapterException("DSA_ERROR", se, getClass());
                      }
  
                  if (inCleanup) 
                  {
                      // Remove inaccurate statement & redundant information. 
  
                      String message =
                                      "Cannot call 'cleanup' on a ManagedConnection while it is still in a " +
                                                      "transaction.";
  
                      ResourceException resX = new DataStoreAdapterException("DSA_ERROR", null, getClass(), message);
  
                      // Use FFDC to log the possible components list. Comment out for now. 
                      FFDCFilter.processException(resX,
                                                  "com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions",
                                                  "1592", this, new Object[] { message, " Possible components: Connection Manager" });
  
                      throw resX;
                  }
  
                  break; 
              }
  
              case WSStateManager.RRS_GLOBAL_TRANSACTION_ACTIVE: 
              { 
                // this case is the same as the previous case except for the rollback, because commit/rollback is illegal during
                // an RRS controlled transaction
                  if (inCleanup) 
                  { 
                      String message = 
                      "Cannot call 'cleanup' on a ManagedConnection while it is still in an " + 
                                      "RRS managed transaction."; 
  
                      ResourceException resX = new DataStoreAdapterException("DSA_ERROR", null, getClass(), message);
  
                      // Use FFDC to log the possible components list. Comment out for now.                                      
                      FFDCFilter.processException(resX, 
                                                  "com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions", 
                                                  "3340", this, new Object[] { message, " Possible components: Connection Manager" }); 
  
                      throw resX; 
                  } 
                  break;
              } 
  
                  // case WSStateManager.RECOVERY_IN_PROGRESS)
                  //     no-op; allow cleanup to set the state back to NO_TRANSACTION_ACTIVE 
          }
  
          CommitOrRollbackOnCleanup cleanupAction = dsConfig.get().commitOrRollbackOnCleanup; 
  
          if (!connectionErrorDetected) // do the checking only if the connection is not bad
          {
              if (cleanupAction != null) 
              {
                  /*
                   * DSConfigurationHelper.COMMIT_OR_ROLLBACK_ON_CLEANUP was set on the DataSource, so we will honor
                   * that property
                   */
                  if (mcf.supportsUOWDetection) {
                      String operation = "none";
                      try {
                          if (mcf.helper.isInDatabaseUnitOfWork(sqlConn)) {
                              /*
                               * If the DB supports UOW Detection and we are in a DB UOW we will commit or rollback per
                               * setting on the DataSource.
                               */
                              if (cleanupAction == CommitOrRollbackOnCleanup.commit) 
                              {
                                  operation = "commit";
                                  if (!mcf.loggedDbUowMessage) {
                                      Tr.info(tc, "RESOLVING_DB_IMPLICIT_TRANSACTIONS", operation);
                                      mcf.loggedDbUowMessage = true;
                                  } else {
                                      if (isTraceOn && tc.isDebugEnabled())
                                          Tr.debug(this, tc, "committing implicit transaction");
                                  }
                                  try{
                                      sqlConn.commit();
                                  } catch(SQLException e){
                                      String message = "Error resolving implicitly started transaction on ManagedConnection.";
                                      Tr.info(tc, "ERROR_RESOLVING_DB_IMPLICIT_TRANSACTIONS", operation, e);
                                      FFDCFilter.processException(e,
                                                                  "com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions",
                                                                  "3588", this, new Object[] { message });
                                      if (isTraceOn && tc.isDebugEnabled()) 
                                      {
                                          Tr.debug(this, tc, "Error resolving implicitly started transaction on ManagedConnection.  Exception is:", e);
                                      }
                                      
                                      LocalTransactionException lte = (LocalTransactionException) (new LocalTransactionException(e.getMessage()).initCause(e));
                                      
                                      throw lte;
                                  }
                              } else if (cleanupAction == CommitOrRollbackOnCleanup.rollback) 
                              {
                                  operation = "rollback";
                                  if (!mcf.loggedDbUowMessage) {
                                      Tr.info(tc, "RESOLVING_DB_IMPLICIT_TRANSACTIONS", operation);
                                      mcf.loggedDbUowMessage = true;
                                  } else {
                                      if (isTraceOn && tc.isDebugEnabled())
                                          Tr.debug(this, tc, "rolling back implicit transaction");
                                  }
                                  try{
                                      sqlConn.rollback();
                                  } catch(SQLException e){
                                      String message = "Error resolving implicitly started transaction on ManagedConnection.";
                                      Tr.info(tc, "ERROR_RESOLVING_DB_IMPLICIT_TRANSACTIONS", operation, e);
                                      FFDCFilter.processException(e,
                                                                  "com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions",
                                                                  "3594", this, new Object[] { message });
                                      if (isTraceOn && tc.isDebugEnabled()) 
                                      {
                                          Tr.debug(this, tc, "Error resolving implicitly started transaction on ManagedConnection.  Exception is:", e);
                                      }
                                      
                                      LocalTransactionException lte = (LocalTransactionException) (new LocalTransactionException(e.getMessage()).initCause(e));
                                      
                                      throw lte; 
                                  }
                              }
                          }
                      } catch (ResourceException e){
                          throw e;
                      } catch (SQLException e){
                          //This is from mcf.helper.isInDatabaseUnitOfWork(sqlConn), presumably
                          String message = "SQLException created in process of cleaning up implicitly started transaction on ManagedConnection.";
                          FFDCFilter.processException(e,
                                                      "com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions",
                                                      "3786", this, new Object[] { message });
                          ResourceException res = ((ResourceException) new ResourceException("Unable to complete connection cleanup; we shouldn't continue to use this connection.").initCause(e));
                          throw res;
                      } 
                  } else // uow detection is not supported  
                  {
                      /*
                       * The DB does not support UOW detection. The xxxOnCleanup action will be done automatically.
                       * No message is logged unless trace is enabled
                       */
                      try {
                          if (cleanupAction == CommitOrRollbackOnCleanup.commit) 
                          {
                              if (isTraceOn && tc.isDebugEnabled()) 
                              {
                                  Tr.debug(this, tc, "Commit connection automatically per custom property " + DSConfig.COMMIT_OR_ROLLBACK_ON_CLEANUP);
                              }
                              // in the case were we dont' know if unit of wrk exists or not, we will only do the commit/rollback if AC = false
                              if (!currentAutoCommit) {
                                  if (isTraceOn && tc.isDebugEnabled())
                                      Tr.debug(this, tc, "AC is false, so we will issue a commit in case there is an implicit tra.");
  
                                  sqlConn.commit();
                              }
                          } else if (cleanupAction == CommitOrRollbackOnCleanup.rollback) 
                          {
                              if (isTraceOn && tc.isDebugEnabled()) 
                              {
                                  Tr.debug(this, tc, "Rollback connection automatically per custom property " + DSConfig.COMMIT_OR_ROLLBACK_ON_CLEANUP);
                              }
                              if (!currentAutoCommit) {
                                  if (isTraceOn && tc.isDebugEnabled())
                                      Tr.debug(this, tc, "AC is false, so we will issue a rollback in case there is an implicit tra.");
  
                                  sqlConn.rollback();
                              }
                          }
                      } catch (Throwable t) {
                          String message = "Error resolving implicitly started transaction on ManagedConnection.";
                          FFDCFilter.processException(t,
                                                      "com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions",
                                                      "3622", this, new Object[] { message });
                          if (isTraceOn && tc.isDebugEnabled()) 
                          {
                              Tr.debug(this, tc, "Error resolving implicitly started transaction on ManagedConnection.  Exception is:", t);
                          }
                      }
                  }
              } else // default behaviour, In this case, we only rollback if unit of work is detected.
              {
                  /*
                   * DSConfigurationHelper.COMMIT_OR_ROLLBACK_ON_CLEANUP was not specified, so we check for any
                   * implicit transactions. If there is an implicit tran we will rollback. Otherwise we will do nothing.
                   */
                  if (mcf.supportsUOWDetection) {
                      try {
                          if (mcf.helper.isInDatabaseUnitOfWork(sqlConn)) {
  
                              if (!mcf.loggedImmplicitTransactionFound) {
                                  Tr.info(tc, "IMPLICIT_TRANSACTION_FOUND");
                                  mcf.loggedImmplicitTransactionFound = true;
                              }
                              sqlConn.rollback();
                          }
                      } catch (Throwable t) {
                          String message = "Error while attempting to rollback database implicitly started transaction on ManagedConnection.";
                          // we are not issueing warnings here because this is the default adn we just need to log it in trace.
                          FFDCFilter.processException(t,
                                                      "com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions",
                                                      "3761", this, new Object[] { message });
  
                          if (isTraceOn && tc.isDebugEnabled())
                              Tr.debug(this, tc, "Error while attempting to rollback database implicitly started transaction on ManagedConnection.", t);
  
                      }
                  }
                  // if the DB does not support UOW Detection do nothing.
                  else {
                      if (!currentAutoCommit
                          && !isTransactional() 
                          && !mcf.warnedAboutNonTransactionalDataSource) {
                          // If AutoCommit=false there might be an unresolved transaction.
                          // We cannot ask the database because it doesn't support unit-of-work detection.
                          // We cannot rely on our internal transaction state because of transactional=false.
                          // CommitOrRollbackOnCleanup is not specified, so we will not be resolving,
                          // the transaction.
  
                          // Issue a warning that we might be leaving an unresolved transaction in
                          // the database.
  
                          Tr.warning(tc, "NONTRAN_DATASOURCE_WARNING",
                                     DataSourceDef.transactional.name() + "=false",
                                     DSConfig.COMMIT_OR_ROLLBACK_ON_CLEANUP
                          );
                          mcf.warnedAboutNonTransactionalDataSource = true;
                      }
                  }
              }
          } //
  
      }