docs: private void cleanupStates() throws ResourceException {
          stateMgr.transtate = WSStateManager.NO_TRANSACTION_ACTIVE;
  
          // set the internal flag that keeps track of RRSGlobalTran to false. since we are cleanning
          //up and we know RRS can't be on by now.
          // now that we cleanup, reset the rrsGlobalTransactionReallyActive flag.
          // not that in the case of RRS and unsharable connections.  Cleanup will not be called after a Global tran is
          // done.  We are ok howevaer, as the rrsGlobalTransactionReallyActive will also be reset in the afterCompletion call
          // by the J2C component.
          rrsGlobalTransactionReallyActive = false;
  
          if (!connectionErrorDetected && sqljContext != null) // Clean up cached SQLJ context and its execution context
              try {
                  Object execCtx = sqljContext.getClass().getMethod("getExecutionContext").invoke(sqljContext);
                  Class<?> ExecutionContext = execCtx.getClass();
                  ExecutionContext.getMethod("setBatching", boolean.class).invoke(execCtx, false);
                  ExecutionContext.getMethod("setBatchLimit", int.class).invoke(execCtx, -7); // sqlj.runtime.ExecutionContext.UNLIMITED_BATCH
                  ExecutionContext.getMethod("setFetchDirection", int.class).invoke(execCtx, 1000); // sqlj.runtime.ResultSetIterator.FETCH_FORWARD
                  ExecutionContext.getMethod("setFetchSize", int.class).invoke(execCtx, 0);
                  ExecutionContext.getMethod("setMaxFieldSize", int.class).invoke(execCtx, 0);
                  ExecutionContext.getMethod("setMaxRows", int.class).invoke(execCtx, 0);
                  ExecutionContext.getMethod("setQueryTimeout", int.class).invoke(execCtx, 0);
              } catch (Exception x) {
                  FFDCFilter.processException(x, getClass().getName(), "3740", this);
                  throw new DataStoreAdapterException("DSA_ERROR", x, getClass());
              }
  
          // Currently only OracleHelper will clean up the connection and returns true.
          // The reason to do that is because Oracle XA driver doesn't allow a xa transaction started
          // when the autoCommit is set to true. Therefore, before we return the Oracle XA connection to the
          // connection pool, we should reset the autocommit of this connection to false.
          //  - SybaseHelper will also return true.
  
          //  - change wasAutoCommitResetByCleanup to wasCleanupReturnTrue
  
          boolean wasCleanupReturnTrue;
  
          try {
  
              if (!connectionErrorDetected) //  only reset the client if the connection is valid
              {
                  //   start  cleanup, clean up will be done only if its been set
                  helper.resetClientInformation(this);
              }
  
              wasCleanupReturnTrue = mcf.helper.doConnectionCleanup(sqlConn);
  
              if (!connectionErrorDetected) 
              {
                  // here is another boundary to enable/disable tracing
                  if (helper.shouldTraceBeEnabled(this))
                      helper.enableJdbcLogging(this);
                  else if (helper.shouldTraceBeDisabled(this))
                      helper.disableJdbcLogging(this);
              }
          } catch (SQLException ex) {
              FFDCFilter.processException(ex, getClass().getName() + ".cleanupStates", "1298", this);
  
              // Don't need to send ConnectionError event when cleanup fails. Throwing an
              // exception on cleanup is enough to signal a connection error. 
              throw new DataStoreAdapterException("DSA_ERROR", ex, WSRdbManagedConnectionImpl.class);
          }
  
  
          //  - reset some Connection properties to their defaults so we don't
          // hand out Connections from the pool with unexpected values.
          // The values are updated directly on the underlying JDBC driver. 
  
          // Since the requested values were reset to the defaults of the underlying JDBC
          // driver, we should consider no properties to have been requested changed.
  
          // reset readonly, catalog and typeMap  
  
          // If doConnectionCleanup indicates it modified ANY connection properties (by
          // returning true) we need to reset ALL connection properties to ensure the
          // modifications are accounted for. 
  
          if (!connectionErrorDetected && 
              (connectionPropertyChanged || wasCleanupReturnTrue)) 
          {
              if (mcf.supportsIsReadOnly) {
                  try {
                      helper.setReadOnly(this, defaultReadOnly, false); 
  
                      // Update the connection request information after switching back to the
                      // default read-only setting.
                      if (connectionSharing == ConnectionSharing.MatchCurrentState)
                      {
                          if (!cri.isCRIChangable()) // create a changable CRI if existing one is not
                              setCRI(WSConnectionRequestInfoImpl.createChangableCRIFromNon(cri));
  
                          cri.setReadOnly(defaultReadOnly);
                      }
                  } catch (SQLException sqle) {
                      FFDCFilter.processException(sqle, getClass().getName() + ".cleanupStates",
                                                  "1226", this);
                      throw new DataStoreAdapterException("DSA_ERROR", sqle, getClass());
                  }
              }
  
              try {
                  setCatalog(defaultCatalog);
  
                  // Update the connection request information after switching back to the
                  // default catalog.
                  if (connectionSharing == ConnectionSharing.MatchCurrentState)
                  {
                      if (!cri.isCRIChangable()) // create a changable CRI if existing one is not
                          setCRI(WSConnectionRequestInfoImpl.createChangableCRIFromNon(cri));
  
                      cri.setCatalog(defaultCatalog);
                  }
              } catch (SQLException sqle) {
                  FFDCFilter.processException(sqle, getClass().getName() + ".cleanupStates",
                                              "1227", this);
                  throw new DataStoreAdapterException("DSA_ERROR", sqle, getClass());
              }
  
              if (mcf.supportsGetTypeMap) {
                  try {
                      setTypeMap(defaultTypeMap);
  
                      // Update the connection request information after switching back to the
                      // default type map.
                      if (connectionSharing == ConnectionSharing.MatchCurrentState)
                      {
                          if (!cri.isCRIChangable()) // create a changable CRI if existing one is not
                              setCRI(WSConnectionRequestInfoImpl.createChangableCRIFromNon(cri));
  
                          cri.setTypeMap(defaultTypeMap);
                      }
                  } catch(SQLFeatureNotSupportedException nse) {
                      // Ignore since we are only attempting to cleanup
                  } catch(UnsupportedOperationException uoe){
                      // Ignore since we are only attempting to cleanup
                  } catch (SQLException sqle) {
                      if(AdapterUtil.isUnsupportedException(sqle)){
                          // ignore unsupported exception
                      } else {
                          FFDCFilter.processException(sqle, getClass().getName() + ".cleanupStates",
                                                      "1228", this);
                          throw new DataStoreAdapterException("DSA_ERROR", sqle, getClass());
                      }
                  }
              }
              
              if(mcf.supportsGetSchema){
                  try{
                      setSchema(defaultSchema);
                      
                      if(connectionSharing == ConnectionSharing.MatchCurrentState){
                          if(!cri.isCRIChangable())
                              setCRI(WSConnectionRequestInfoImpl.createChangableCRIFromNon(cri));
                          cri.setSchema(defaultSchema);
                      }
                  } catch(SQLFeatureNotSupportedException nse) {
                      // Ignore since we are only attempting to cleanup
                  } catch(UnsupportedOperationException uoe){
                      // Ignore since we are only attempting to cleanup
                  } catch (SQLException sqle) {
                      if(AdapterUtil.isUnsupportedException(sqle)){
                          // ignore unsupported exception
                      } else {
                          FFDCFilter.processException(sqle, getClass().getName() + ".cleanupStates",
                                                      "3644", this);
                          throw new DataStoreAdapterException("DSA_ERROR", sqle, getClass());
                      }
                  }
              }
  
              if (!AdapterUtil.match(currentShardingKey, initialShardingKey)
               || !AdapterUtil.match(currentSuperShardingKey, initialSuperShardingKey)) {
                  try {
                      setShardingKeys(initialShardingKey, initialSuperShardingKey);
  
                      // Update the connection request information after switching back to the
                      // default sharding keys.
                      if (connectionSharing == ConnectionSharing.MatchCurrentState)
                      {
                          if (!cri.isCRIChangable()) // create a changable CRI if existing one is not
                              setCRI(WSConnectionRequestInfoImpl.createChangableCRIFromNon(cri));
  
                          cri.setShardingKey(initialShardingKey);
                          cri.setSuperShardingKey(initialSuperShardingKey);
                      }
                  } catch (SQLException sqle) {
                      FFDCFilter.processException(sqle, getClass().getName(), "2959", this);
                      throw new DataStoreAdapterException("DSA_ERROR", sqle, getClass());
                  }
              }
  
              if(mcf.supportsGetNetworkTimeout){
                  try{
                      final ExecutorService libertyThreadPool = mcf.connectorSvc.getLibertyThreadPool();
                      // setNetworkTimeout is the only JDBC Connection property that may perform access checks
                      if (System.getSecurityManager() == null) {
                          setNetworkTimeout(libertyThreadPool, defaultNetworkTimeout);
                      } else {
                          try {
                              AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
                                  @Override
                                  public Void run() throws Exception {
                                      setNetworkTimeout(libertyThreadPool, defaultNetworkTimeout);
                                      return null;
                                  }
                              });
                          } catch (PrivilegedActionException e) {
                              if (e.getException() instanceof SQLException)
                                  throw (SQLException) e.getException();
                              throw (RuntimeException) e.getException();
                          }
                      }
                      
                      if(connectionSharing == ConnectionSharing.MatchCurrentState){
                          if(!cri.isCRIChangable())
                              setCRI(WSConnectionRequestInfoImpl.createChangableCRIFromNon(cri));
                          cri.setNetworkTimeout(defaultNetworkTimeout);
                      }
                  } catch(SQLFeatureNotSupportedException nse) {
                      // Ignore since we are only attempting to cleanup
                  } catch(UnsupportedOperationException uoe){
                      // Ignore since we are only attempting to cleanup
                  } catch (SQLException sqle) {
                      if(AdapterUtil.isUnsupportedException(sqle)){
                          // ignore unsupported exception
                      } else {
                          FFDCFilter.processException(sqle, getClass().getName() + ".cleanupStates",
                                                      "3672", this);
                          throw new DataStoreAdapterException("DSA_ERROR", sqle, getClass());
                      }
                  }
              }
  
              connectionPropertyChanged = false;
  
              //  - get the autocommit value, isolation level value and holdability value from the native connection
              if (wasCleanupReturnTrue) {
                  try {
                      currentAutoCommit = sqlConn.getAutoCommit();
                      if (cachedConnection != null) 
                          cachedConnection.setCurrentAutoCommit(currentAutoCommit, key);
                  } catch (SQLException sqle) {
                      FFDCFilter.processException(sqle, getClass().getName() + ".cleanupStates",
                                                  "1308", this);
                      throw new DataStoreAdapterException("DSA_ERROR", sqle, getClass());
                  }
  
                  try {
                      currentTransactionIsolation = sqlConn.getTransactionIsolation();
                      if (cachedConnection != null) 
                          cachedConnection.setCurrentTransactionIsolation(currentTransactionIsolation, key);
  
                      // in case doConnectionCleanup changed the value, we need to synchup the cri if isoswitching is not supported.
                      if (!supportIsolvlSwitching && connectionSharing == ConnectionSharing.MatchCurrentState)
                      {
                          if (!cri.isCRIChangable()) // only set the cri if its not one of the static ones.
                              setCRI(WSConnectionRequestInfoImpl.createChangableCRIFromNon(cri));
  
                          cri.setTransactionIsolationLevel(currentTransactionIsolation);
                      }
  
                  } catch (SQLException sqle) {
                      FFDCFilter.processException(sqle, getClass().getName() + ".cleanupStates",
                                                  "1318", this);
                      throw new DataStoreAdapterException("DSA_ERROR", sqle, getClass());
                  }
  
                  try {
                      currentHoldability = mcf.getHelper().getHoldability(sqlConn);
  
                      // Update the connection request information after switching back to the
                      // default holdability.
                      if (connectionSharing == ConnectionSharing.MatchCurrentState)
                      {
                          if (!cri.isCRIChangable()) // create a changable CRI if existing one is not
                              setCRI(WSConnectionRequestInfoImpl.createChangableCRIFromNon(cri));
  
                          cri.setHoldability(defaultHoldability);
                      }
                  } catch (SQLException sqle) {
                      FFDCFilter.processException(sqle, getClass().getName() + ".cleanupStates()", "3626", this); 
                      throw new DataStoreAdapterException("DSA_ERROR", sqle, getClass());
                  }
              }
              //  ends
  
              //if non transactional datasource then we need to make sure that
              // the autocomit value matches the database default as we would never
              // change it ourselves due to the fact that we don't enlist in a tran
              if (!isTransactional() && (currentAutoCommit != defaultAutoCommit)) 
              {
                  try {
                      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                          Tr.debug(this, tc, "autoCommit on connection doesn't match the database default, setting it to: ",
                                   defaultAutoCommit); 
                      }
  
                      sqlConn.setAutoCommit(defaultAutoCommit);
                      currentAutoCommit = defaultAutoCommit;
  
                      if (cachedConnection != null)
                          cachedConnection.setCurrentAutoCommit(defaultAutoCommit, key);
                  } catch (SQLException sqle) {
                      FFDCFilter.processException(sqle, getClass().getName() + ".cleanupStates()", "3652", this);
                      throw new DataStoreAdapterException("DSA_ERROR", sqle, getClass());
                  }
              }
  
  
          } else if (cachedConnection != null && !connectionErrorDetected)
              cachedConnection.setCurrentAutoCommit(defaultAutoCommit, key);
  
          // Reset the flag here to be safe, but realize we cannot rely on cleanup being called
          // after every global transaction. 
          wasLazilyEnlistedInGlobalTran = false; 
      }