Will create (or recreate) if necessary the temporary login data.<br>
Will create its own transaction - therefore the given connection must not have any active transaction.
342624
public static Duet getId(DbConn cnx)
    {
        Duet currentLoginData = logindata; // Pointer copy to avoid having it reset under us during this method run.
        RUser currentUser = user;

        if (useAuth == null)
        {
            useAuth = Boolean.parseBoolean(GlobalParameter.getParameter(cnx, "enableWsApiAuth", "true"));
        }

        if (currentLoginData == null)
        {
            currentLoginData = new Duet();
            currentLoginData.pass = null;
            currentLoginData.usr = null;
            logindata = currentLoginData;
        }

        if (!useAuth)
        {
            jqmlogger.debug("The client web API calls will not use any authentication");
            return currentLoginData;
        }

        // Renew one day before limit, to ensure account is valid for a day.
        Calendar renewalLimit = null;
        if (currentUser != null)
        {
            renewalLimit = (Calendar) currentUser.getExpirationDate().clone(); // clone. otherwise we modify the user object next line!
            renewalLimit.add(Calendar.DAY_OF_YEAR, -1);
        }

        if (currentUser == null || renewalLimit == null || renewalLimit.before(Calendar.getInstance()))
        {
            synchronized (lock)
            {
                if (currentUser == null || currentUser.getExpirationDate().before(Calendar.getInstance()))
                {
                    jqmlogger.debug("The client API will create an internal secret to access the simple API");

                    // Create new
                    String login = UUID.randomUUID().toString();

                    secret = UUID.randomUUID().toString();
                    ByteSource salt = new SecureRandomNumberGenerator().nextBytes();
                    String hash = new Sha512Hash(secret, salt, 100000).toHex();
                    String saltS = salt.toHex();

                    Calendar expiration = Calendar.getInstance();
                    expiration.add(Calendar.DAY_OF_YEAR, 2);

                    int id = RUser.create(cnx, login, hash, saltS, expiration, true, "administrator");
                    currentUser = RUser.select_id(cnx, id);
                    user = currentUser;

                    currentLoginData = new Duet();
                    currentLoginData.pass = secret;
                    currentLoginData.usr = login;
                    logindata = currentLoginData;

                    // Purge all old internal accounts
                    cnx.runUpdate("user_delete_expired_internal");

                    cnx.commit();
                }
            }
        }

        return currentLoginData;
    }
421126
@Override
    public synchronized void beginTransaction() throws DatabaseEngineRuntimeException {
        /*
         * It makes sense trying to reconnect since it's the beginning of a transaction.
         */
        try {
            getConnection();
            if (!conn.getAutoCommit()) { //I.E. Manual control
                logger.debug("There's already one transaction active");
                return;
            }

            conn.setAutoCommit(false);
        } catch (final Exception ex) {
            throw new DatabaseEngineRuntimeException("Error occurred while starting transaction", ex);
        }
    }
578290
public void createTransaction(String scope, String streamName, Duration latency) {
        DYNAMIC_LOGGER.incCounterValue(globalMetricName(CREATE_TRANSACTION), 1);
        DYNAMIC_LOGGER.incCounterValue(CREATE_TRANSACTION, 1, streamTags(scope, streamName));
        createTransactionLatency.reportSuccessValue(latency.toMillis());
    }
1294441
public CreateTransactionResult createTransaction(
            final long connectionId,
            final long txnId,
            final long uniqueId,
            final StoredProcedureInvocation invocation,
            final boolean isReadOnly,
            final boolean isSinglePartition,
            final boolean isEveryPartition,
            final int partition,
            final int messageSize,
            long nowNanos,
            final boolean isForReplay)
    {
        return m_dispatcher.createTransaction(
                connectionId,
                txnId,
                uniqueId,
                invocation,
                isReadOnly,
                isSinglePartition,
                isEveryPartition,
                new int [] { partition },
                messageSize,
                nowNanos,
                isForReplay);
    }
1072790
def make_transaction(self):
        
        if self.pk:
            raise CannotRecreateTransactionOnRecurredCost(
                'The transaction for this recurred cost has already been created. You cannot create it again.'
            )

        amount = self.recurring_cost.get_amount(self.billing_cycle)

        # It is quite possible that there will be nothing to bill, in which
        # case we cannot create a transaction with no legs, nor can we create
        # legs with zero values. Therefore we don't create any transaction.
        if not amount:
            return None

        self.transaction = Transaction.objects.create(
            description='Created by recurring cost',
            date=self.billing_cycle.date_range.lower
        )

        # Use the SplitManager's custom queryset's split() method to get the
        # amount to be billed for each split
        splits = self.recurring_cost.splits.all().split(amount)

        # Create the transaction leg for the outbound funds
        # (normally to an expense account)
        self.transaction.legs.add(Leg.objects.create(
            transaction=self.transaction,
            amount=Money(amount, self.recurring_cost.currency),
            account=self.recurring_cost.to_account,
        ))

        for split, split_amount in splits:
            # Create the transaction legs for the inbound funds
            # (from housemate accounts)
            if split_amount:
                self.transaction.legs.add(Leg.objects.create(
                    transaction=self.transaction,
                    amount=Money(split_amount * -1, self.recurring_cost.currency),
                    account=split.from_account,
                ))

        return self.transaction
272753
@Override
	public final Connection createConnection() throws JMSException
    {
    	String username = getStringProperty(Context.SECURITY_PRINCIPAL,null);
    	String password = getStringProperty(Context.SECURITY_CREDENTIALS,null);
    	
        return createConnection(username,password);
    }
1066604
public int create(DatabaseConnection databaseConnection, T data, ObjectCache objectCache) throws SQLException {
		if (mappedInsert == null) {
			mappedInsert = MappedCreate.build(dao, tableInfo);
		}
		int result = mappedInsert.insert(databaseType, databaseConnection, data, objectCache);
		if (dao != null && !localIsInBatchMode.get()) {
			dao.notifyChanges();
		}
		return result;
	}
66066
@Override
    public SICoreConnection createConnection(String userName, String password,
                                             Map connectionProperties) throws SIResourceException,
                    SINotAuthorizedException, SIAuthenticationException {
        if (TraceComponent.isAnyTracingEnabled()
            && CoreSPIConnFactory.tc.isEntryEnabled())
            SibTr.entry(CoreSPIConnFactory.tc, "createConnection",
                        new Object[] { userName, connectionProperties });

        // Check that the Messaging Engine is started
        checkStarted();

        // Security context associated with logged-on principal.
        Subject subject = null;

        // Security Code changes for Liberty: Sharath Start
        try {
            subject = _authentication.login(userName, password);
        } catch (MessagingAuthenticationException e) {
            throw new SIAuthenticationException(e.getMessage());
        }
        SICoreConnection connection = createConnection(subject, connectionProperties);
        if (TraceComponent.isAnyTracingEnabled()
            && CoreSPIConnFactory.tc.isEntryEnabled())
            SibTr.exit(CoreSPIConnFactory.tc, "createConnection", connection);
        return connection;
        // Security Code changes for Liberty: Sharath End
    }
1328815
protected boolean isExistingTransaction(Object transaction) {
        ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) transaction;

        return super.isExistingTransaction(actualTransactionObject
                .getHibernateTransactionObject());
    }
106318
@Override
    public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createSession", new Object[] { transacted, acknowledgeMode });

        JmsSessionImpl jmsSession = null;

        // throw an exception if the connection is closed.
        checkClosed();

        // mark that the client id cannot be changed.
        fixClientID();

        // enforce consistency on transacted flag and acknowledge mode.
        if (transacted) {
            acknowledgeMode = Session.SESSION_TRANSACTED;
        }
        if (!transacted && isManaged) {
            if (acknowledgeMode == Session.CLIENT_ACKNOWLEDGE) {
                throw (JMSException) JmsErrorUtils.newThrowable(JMSException.class,
                                                                "INVALID_ACKNOWLEDGE_MODE_CWSIA0514",
                                                                new Object[] { acknowledgeMode },
                                                                tc
                                );
            }
            // if the ackmode is dups_ok then set it to dups_ok, for all the other combination 
            // set it to auto_ack
            if (acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE)
                acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE;
            else
                acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
        }

        // create the jca session.
        boolean internallyTransacted = (transacted
                                        || acknowledgeMode == Session.CLIENT_ACKNOWLEDGE
                                        || acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE);
        JmsJcaSession jcaSession = createJcaSession(internallyTransacted);

        // Lock here so that another thread using the same connection doesn't reset the 
        // coreConnection to something else as as we are instantiating the Session 
        synchronized (this)
        {
            try
            {
                // We potentially have a new coreConnection becuase the creation of the JcaSession
                // detected that the coreConnection is now invalid and so a new managedConnection
                // and coreConnection was created. So reset the coreConnection for this JmsConnection
                // to the new one or we just set the old one again.
                coreConnection = jcaSession.getSICoreConnection();
            } catch (IllegalStateException e)
            {
                FFDCFilter.processException(e, "com.ibm.ws.sib.api.jms.impl.JmsConnectionImpl", "createSession#2", this);

                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(this, tc, "createSession", jmsSession);

                throw (JMSException) JmsErrorUtils.newThrowable(
                                                                JMSException.class,
                                                                "JCA_CREATE_SESS_CWSIA0024",
                                                                null,
                                                                e,
                                                                "JmsConnectionImpl.createSession#2",
                                                                this,
                                                                tc);
            }
            // instantiate the jms session, and add it to this connection's session list.
            jmsSession = instantiateSession(transacted, acknowledgeMode, coreConnection, jcaSession);
        }
        synchronized (stateLock) {
            sessions.add(jmsSession);
            // d353701 - output a warning message if there are 'lots' of sessions active.
            if (sessions.size() % SESSION_WARNING_THRESHOLD == 0) {
                // We wish to tell the user which line of their application created the session,
                // so we must obtain a line of stack trace from their application.
                String errorLocation = JmsErrorUtils.getFirstApplicationStackString();
                SibTr.warning(tc, "MANY_SESSIONS_WARNING_CWSIA0027", new Object[] { "" + sessions.size(), errorLocation });
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "createSession", jmsSession);
        return jmsSession;
    }
1314400
private void setupConnection(final Connection connection) throws ConnectionSetupException
   {
      try {
         if (networkTimeout == UNINITIALIZED) {
            networkTimeout = getAndSetNetworkTimeout(connection, validationTimeout);
         }
         else {
            setNetworkTimeout(connection, validationTimeout);
         }

         if (connection.isReadOnly() != isReadOnly) {
            connection.setReadOnly(isReadOnly);
         }

         if (connection.getAutoCommit() != isAutoCommit) {
            connection.setAutoCommit(isAutoCommit);
         }

         checkDriverSupport(connection);

         if (transactionIsolation != defaultTransactionIsolation) {
            connection.setTransactionIsolation(transactionIsolation);
         }

         if (catalog != null) {
            connection.setCatalog(catalog);
         }

         if (schema != null) {
            connection.setSchema(schema);
         }

         executeSql(connection, config.getConnectionInitSql(), true);

         setNetworkTimeout(connection, networkTimeout);
      }
      catch (SQLException e) {
         throw new ConnectionSetupException(e);
      }
   }
88277
function createTransaction(dbInfo, mode, callback, retries) {
    if (retries === undefined) {
        retries = 1;
    }

    try {
        var tx = dbInfo.db.transaction(dbInfo.storeName, mode);
        callback(null, tx);
    } catch (err) {
        if (retries > 0 && (!dbInfo.db || err.name === 'InvalidStateError' || err.name === 'NotFoundError')) {
            return Promise$1.resolve().then(function () {
                if (!dbInfo.db || err.name === 'NotFoundError' && !dbInfo.db.objectStoreNames.contains(dbInfo.storeName) && dbInfo.version <= dbInfo.db.version) {
                    // increase the db version, to create the new ObjectStore
                    if (dbInfo.db) {
                        dbInfo.version = dbInfo.db.version + 1;
                    }
                    // Reopen the database for upgrading.
                    return _getUpgradedConnection(dbInfo);
                }
            }).then(function () {
                return _tryReconnect(dbInfo).then(function () {
                    createTransaction(dbInfo, mode, callback, retries - 1);
                });
            })["catch"](callback);
        }

        callback(err);
    }
}
277948
def create(self, path, value=b"", acl=None, ephemeral=False,
               sequence=False):
        
        super(XTransactionRequest, self).create(path, to_bytes(value), acl, ephemeral, sequence)
1115916
private Session createConnection() {

        /* reorder locations */
        List<String> locations = Lists.newArrayList(split.getReplicas());
        Collections.sort(locations, new DeepPartitionLocationComparator());

        Exception lastException = null;

        LOG.debug("createConnection: " + locations);
        for (String location : locations) {

            try {
                return trySessionForLocation(location, config, false).left;
            } catch (Exception e) {
                LOG.error("Could not get connection for: {}, replicas: {}", location, locations);
                lastException = e;
            }
        }

        throw new DeepIOException(lastException);
    }
45486
public synchronized void createConnection()
    {
        if (scribeClient != null) {
            try {
                connectionRetries.incrementAndGet();
                scribeClient.closeLogger();
                scribeClient.openLogger();
                isClosed.set(false);

                log.info("Connection to Scribe established");
            }
            catch (TTransportException e) {
                log.warn("Unable to connect to Scribe: {}", e.getLocalizedMessage());
                scribeClient.closeLogger();
            }
        }
        else {
            log.warn("Scribe client has not been set up correctly.");
        }
    }
482536
private Connection createRealConnection(final long timeoutMillis) throws SQLException {

      if(timeoutMillis < 1L) {

         String usePassword = getPassword();

         Connection conn = dbConnection.datasource == null ?
                 DriverManager.getConnection(dbConnection.connectionString, dbConnection.user, usePassword) :
                 dbConnection.datasource.getConnection(dbConnection.user, usePassword);
         if(conn != null) {
            return conn;
         } else {
            throw new SQLException("Unable to create connection: driver/datasource returned [null]");
         }

      } else {

         try {
            return connectionTimeLimiter.callWithTimeout(() -> createRealConnection(0L), timeoutMillis, TimeUnit.MILLISECONDS);
         } catch(UncheckedTimeoutException ute) {
            throw new SQLException("Unable to create connection after waiting " + timeoutMillis + " ms");
         } catch(Exception e) {
            throw new SQLException("Unable to create connection: driver/datasource", e);
         }
      }
   }
1114875
public Connection createDBConnection() {
        if (mDBConnInfo != null) {
            return getConnectionViaDriverMangaer(mDBConnInfo.DBDriver, mDBConnInfo.DBUrl, mDBConnInfo.DBUser, mDBConnInfo.DBPassword);
        } else {
            return null;
        }
    }