Get Connection. Support transaction if Connection in ThreadLocal
322083
public Connection getConnection() throws SQLException {
		Connection conn = threadLocal.get();
		if (conn != null)
			return conn;
		return showSql ? new SqlReporter(dataSource.getConnection()).getConnection() : dataSource.getConnection();
	}
274978
def connection(self, shareable=False):
        
        try:
            con = self.thread.connection
        except AttributeError:
            con = self.steady_connection()
            if not con.threadsafety():
                raise NotSupportedError("Database module is not thread-safe.")
            self.thread.connection = con
        con._ping_check()
        return con
1339135
private int tryAcquireExclusiveTransaction(@NotNull final Thread thread, final int timeout) {
        long nanos = TimeUnit.MILLISECONDS.toNanos(timeout);
        try (CriticalSection ignored = criticalSection.enter()) {
            if (getThreadPermits(thread) > 0) {
                throw new ExodusException("Exclusive transaction can't be nested");
            }
            final Condition condition = criticalSection.newCondition();
            final long currentOrder = acquireOrder++;
            regularQueue.put(currentOrder, condition);
            while (acquiredPermits > 0 || regularQueue.firstKey() != currentOrder) {
                try {
                    nanos = condition.awaitNanos(nanos);
                    if (nanos < 0) {
                        break;
                    }
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                    break;
                }
            }
            if (acquiredPermits == 0 && regularQueue.firstKey() == currentOrder) {
                regularQueue.pollFirstEntry();
                acquiredPermits = availablePermits;
                threadPermits.put(thread, availablePermits);
                return availablePermits;
            }
            regularQueue.remove(currentOrder);
            notifyNextWaiters();
        }
        return 0;
    }
788809
final LocalTransactionCoordinator suspendLocalTx()
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEventEnabled())
        {
            LocalTransactionCoordinator currentLTC = ltcCurrent.getLocalTranCoord();
            if (currentLTC != null)
            {
                Tr.event(tc, "Suspending LTC cntxt: tid=" + Integer.toHexString(currentLTC.hashCode()) + "(LTC)");
            }
        }

        LocalTransactionCoordinator suspendedLocalTx = ltcCurrent.suspend();

        if (isTraceOn && suspendedLocalTx != null && TETxLifeCycleInfo.isTraceEnabled()) // d171555
        {
            TETxLifeCycleInfo.traceLocalTxSuspend("" + System.identityHashCode(suspendedLocalTx), "Suspend Local Tx");
        }

        return suspendedLocalTx;
    }
491700
protected void commitLocalConnection(Connection connection) {
    try {
      if (connection != null ) {
        connection.commit();
      }
    } catch (SQLException e) {
      if (logger.isTraceEnabled()) {
        logger.trace(e.getMessage());
      }
    }
  }
124444
final LocalTransactionCoordinator suspendLocalTx() // 131880-6
    {
        // d173641 Begins
        LocalTransactionCoordinator lCoord = null; // d165585
        if (TraceComponent.isAnyTracingEnabled() && // d527372
            (tc.isEventEnabled() ||
            TETxLifeCycleInfo.isTraceEnabled()))
        {
            lCoord = getLocalCoord();

            if (lCoord != null &&
                TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
            {
                Tr.event(tc, "Suspending LTC cntxt: tid=" +
                             Integer.toHexString(lCoord.hashCode()) + "(LTC)");
            }
            // 173641 Ends
        }

        // d165585 Begins
        LocalTransactionCoordinator rtnVal = ltcCurrent.suspend(); // 131880-6

        if (lCoord != null &&
            TraceComponent.isAnyTracingEnabled() && // d527372
            TETxLifeCycleInfo.isTraceEnabled()) // d171555
        {
            TETxLifeCycleInfo.traceLocalTxSuspend("" + System.identityHashCode(lCoord), "Suspend Local Tx");
        }
        return rtnVal;
        // d165585 Ends
    }
676526
def transactional_async(func, args, kwds, **options):
  """"""
  options.setdefault('propagation', datastore_rpc.TransactionOptions.ALLOWED)
  if args or kwds:
    return transaction_async(lambda: func(*args, **kwds), **options)
  return transaction_async(func, **options)
1220817
private TransactionSupportEnum getTransactionSupport(Connector connector, Activation activation)
   {
      if (activation.getTransactionSupport() != null)
         return activation.getTransactionSupport();

      if (connector.getResourceadapter().getOutboundResourceadapter() != null)
         return connector.getResourceadapter().getOutboundResourceadapter().getTransactionSupport();

      // We have to assume XA for pure inbound, overrides is done with activation
      return TransactionSupportEnum.XATransaction;
   }
1060756
public void localCommit()
    {
        if (log.isDebugEnabled()) log.debug("commit was called");
        if (!this.isInLocalTransaction)
        {
            throw new TransactionNotInProgressException("Not in transaction, call begin() before commit()");
        }
        try
        {
            if(!broker.isManaged())
            {
                if (batchCon != null)
                {
                    batchCon.commit();
                }
                else if (con != null)
                {
                    con.commit();
                }
            }
            else
            {
                if(log.isDebugEnabled()) log.debug(
                        "Found managed environment setting in PB, will skip Connection.commit() call");
            }
        }
        catch (SQLException e)
        {
            log.error("Commit on underlying connection failed, try to rollback connection", e);
            this.localRollback();
            throw new TransactionAbortedException("Commit on connection failed", e);
        }
        finally
        {
            this.isInLocalTransaction = false;
            restoreAutoCommitState();
            this.releaseConnection();
        }
    }
201238
@Nullable
    TransactionOutput getConnectedOutput(Map<Sha256Hash, Transaction> transactions) {
        Transaction tx = transactions.get(outpoint.getHash());
        if (tx == null)
            return null;
        return tx.getOutputs().get((int) outpoint.getIndex());
    }
307466
private SITransaction getCurrentTransaction() {

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, "getCurrentTransaction");
        }

        SITransaction currentTransaction = null;

        // Is there a current local transaction?

        if (_localTransaction != null) {

            currentTransaction = _localTransaction.getCurrentTransaction();

        }

        // If not, is there a current global transaction?

        if ((currentTransaction == null) && (_xaResource != null)) {

            currentTransaction = _xaResource.getCurrentTransaction();

        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr
                    .exit(this, TRACE, "getCurrentTransaction",
                            currentTransaction);
        }
        return currentTransaction;

    }
142883
def get_transaction(self, transaction_id, **params):
        """"""
        return self.api_client.get_transaction(self.id, transaction_id, **params)
804557
def instance_thread_local(name, value = nil)
      sc = class << self
        extend DSLKit::ThreadLocal
        self
      end
      sc.thread_local name, value
      self
    end
1318920
public Connection getConnection() throws FetchException {
        try {
            if (mOpenConnections == null) {
                throw new FetchException("Repository is closed");
            }

            JDBCTransaction txn = localTransactionScope().getTxn();
            if (txn != null) {
                // Return the connection used by the current transaction.
                return txn.getConnection();
            }

            // Get connection outside lock section since it may block.
            Connection con = mDataSource.getConnection();
            con.setAutoCommit(true);

            mOpenConnectionsLock.lock();
            try {
                if (mOpenConnections == null) {
                    con.close();
                    throw new FetchException("Repository is closed");
                }
                mOpenConnections.put(con, null);
            } finally {
                mOpenConnectionsLock.unlock();
            }

            return con;
        } catch (Exception e) {
            throw toFetchException(e);
        }
    }
255364
public final void onPrepareCommand(GlobalTransaction globalTransaction, boolean local) {
      //NB: If I want to give up using the InboundInvocationHandler, I can create the remote transaction
      //here, just overriding the handlePrepareCommand
      TransactionStatistics txs = getTransactionStatistic(globalTransaction, local);
      if (txs == null) {
         log.prepareOnUnexistingTransaction(globalTransaction == null ? "null" : globalTransaction.globalId());
         log.error("Trying to invoke onPrepareCommand() but no transaction is associated");
         return;
      }
      txs.onPrepareCommand();
   }
192146
protected void checkForBatchSupport(Connection conn)
    {
        if (!m_batchUpdatesChecked)
        {
            DatabaseMetaData meta;
            try
            {
                meta = conn.getMetaData();
                m_supportsBatchUpdates = meta.supportsBatchUpdates();
            }
            catch (Throwable th)
            {
                log.info("Batch support check failed", th);
                m_supportsBatchUpdates = false;
            }
            finally
            {
                m_batchUpdatesChecked = true;
            }
        }
    }
1225530
private static void hasMcfTransactionSupport(PrintStream out, PrintStream error, String classname, URLClassLoader cl)
   {
      try
      {
         out.print("  TransactionSupport: ");
         
         Class<?> mcfClz = Class.forName(classname, true, cl);
         ManagedConnectionFactory mcf = (ManagedConnectionFactory)mcfClz.newInstance();

         if (hasInterface(mcf.getClass(),  "javax.resource.spi.TransactionSupport"))
         {
            out.println("Yes");
         } 
         else
         {
            out.println("No");
         }
      }
      catch (Throwable t)
      {
         // Nothing we can do
         t.printStackTrace(error);
         out.println("Unknown");
      }
   }