Set transaction isolation.

@param level transaction level.
@throws SQLException if transaction level is unknown
195976
public void setTransactionIsolation(final int level) throws SQLException {
    cmdPrologue();
    lock.lock();
    try {
      String query = "SET SESSION TRANSACTION ISOLATION LEVEL";
      switch (level) {
        case Connection.TRANSACTION_READ_UNCOMMITTED:
          query += " READ UNCOMMITTED";
          break;
        case Connection.TRANSACTION_READ_COMMITTED:
          query += " READ COMMITTED";
          break;
        case Connection.TRANSACTION_REPEATABLE_READ:
          query += " REPEATABLE READ";
          break;
        case Connection.TRANSACTION_SERIALIZABLE:
          query += " SERIALIZABLE";
          break;
        default:
          throw new SQLException("Unsupported transaction isolation level");
      }
      executeQuery(query);
      transactionIsolationLevel = level;
    } finally {
      lock.unlock();
    }
  }
1294891
def set_sqlite_autocommit(cn, autocommit):
  """"""
  if isinstance(autocommit, bool):
    cn.isolation_level = None if autocommit else ""
  else:
    cn.isolation_level = autocommit
326575
public void setIsolation(int level) {

        if (isInMidTransaction()) {
            throw Error.error(ErrorCode.X_25001);
        }

        if (level == SessionInterface.TX_READ_UNCOMMITTED) {
            isReadOnly = true;
        }

        isolationMode = level;

        if (isolationMode != isolationModeDefault) {
            database.logger.writeToLog(this, getTransactionIsolationSQL());
        }
    }
194086
@Override
	public void setReadOnly(boolean readOnly) throws RemoteException {
		if (this.readOnly != readOnly) {
			tx.commit();
			this.readOnly = readOnly;
			try {
				tx = VanillaDb.txMgr().newTransaction(isolationLevel, readOnly);
			} catch (Exception e) {
				throw new RemoteException("error creating transaction ", e);
			}
		}
	}
276034
private static IsolationLevel selectIsolationLevel(DatabaseMetaData md,
                                                       IsolationLevel desiredLevel)
        throws SQLException, RepositoryException
    {
        while (!md.supportsTransactionIsolationLevel(mapIsolationLevelToJdbc(desiredLevel))) {
            switch (desiredLevel) {
            case READ_UNCOMMITTED:
                desiredLevel = IsolationLevel.READ_COMMITTED;
                break;
            case READ_COMMITTED:
                desiredLevel = IsolationLevel.REPEATABLE_READ;
                break;
            case REPEATABLE_READ:
                desiredLevel = IsolationLevel.SERIALIZABLE;
                break;
            case SNAPSHOT:
                desiredLevel = IsolationLevel.SERIALIZABLE;
                break;
            case SERIALIZABLE: default:
                return null;
            }
        }
        return desiredLevel;
    }
690594
public void setLoggerLevel(@Nonnull String loggerName, @Nullable String level) {
        logger.info("setLoggerLevel(" + loggerName + "," + level + ")");
        try {
            Level levelAsObject = Level.toLevel(level);
            LogManager.getLogger(loggerName).setLevel(levelAsObject);
        } catch (RuntimeException e) {
            logger.warn("Exception setting logger " + loggerName + " to level " + level, e);
            throw e;
        }
    }
636663
public Transaction enter(IsolationLevel level) {
        mLock.lock();
        try {
            TransactionImpl<Txn> parent = mActive;
            IsolationLevel actualLevel = mTxnMgr.selectIsolationLevel(parent, level);
            if (actualLevel == null) {
                if (parent == null) {
                    throw new UnsupportedOperationException
                        ("Desired isolation level not supported: " + level);
                } else {
                    throw new UnsupportedOperationException
                        ("Desired isolation level not supported: " + level
                         + "; parent isolation level: " + parent.getIsolationLevel());
                }
            }

            TransactionImpl<Txn> txn = new TransactionImpl<Txn>(this, parent, false, actualLevel);
            mActive = txn;

            mTxnMgr.entered(txn, parent);

            return txn;
        } finally {
            mLock.unlock();
        }
    }
893324
public void withVoidTransaction(@NotNull Isolation isolation, @NotNull VoidTransactionCallback callback) {
        withVoidTransaction(Propagation.REQUIRED, isolation, callback);
    }
1059966
@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);
      }
   }
1295850
protected final void setLevel(int traceLevel) {

        switch (traceLevel) {
            case Trace.Level_All:
                debugEnabled = true;
                eventEnabled = true;
                entryEnabled = true;
                break;

            case Trace.Level_Entry:
                debugEnabled = false;
                eventEnabled = false;
                entryEnabled = true;
                break;

            case Trace.Level_Debug:
                debugEnabled = true;
                eventEnabled = false;
                entryEnabled = false;
                break;

            case Trace.Level_Event:
                debugEnabled = false;
                eventEnabled = true;
                entryEnabled = false;
                break;

            case Trace.Level_None:
                debugEnabled = false;
                eventEnabled = false;
                entryEnabled = false;
                break;

            default:
        } // switch (traceLevel).

    }
859520
private function resetTransactionNestingLevel()
    {
        if (! $this->selfReflectionNestingLevelProperty instanceof \ReflectionProperty) {
            $reflection = new \ReflectionClass(DBALConnection::class);

            // Private property has been renamed in DBAL 2.9.0+
            if ($reflection->hasProperty('transactionNestingLevel')) {
                $this->selfReflectionNestingLevelProperty = $reflection->getProperty('transactionNestingLevel');
            } else {
                $this->selfReflectionNestingLevelProperty = $reflection->getProperty('_transactionNestingLevel');
            }

            $this->selfReflectionNestingLevelProperty->setAccessible(true);
        }

        $this->selfReflectionNestingLevelProperty->setValue($this, 0);
    }
716195
public static void addLevelsToDatabase(final BuildDatabase buildDatabase, final Level level) {
        // Add the level to the database
        buildDatabase.add(level);

        // Add the child levels to the database
        for (final Level childLevel : level.getChildLevels()) {
            addLevelsToDatabase(buildDatabase, childLevel);
        }
    }
126198
@Override
  public void close() throws SQLException {
    if (last != null) {
      last.close();
      if (!con.isClosed()) {
        if (!con.getAutoCommit()) {
          try {
            con.rollback();
          } catch (SQLException ignored) {
          }
        }
      }
    }
    try {
      con.close();
    } finally {
      con = null;
    }
  }
1165819
public static void release(Statement statement, Connection connection) {

        if (statement != null) {
            try {
                statement.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        if (connection != null) {
            JDBCUtils.release(connection);
        }
    }
1010832
public function setTransactionIsolationLevel($level = null)
    {
        $this->_connect();
        $sql = null;

        // Default transaction level in sql server
        if ($level === null)
        {
            $level = SQLSRV_TXN_READ_COMMITTED;
        }

        switch ($level) {
            case SQLSRV_TXN_READ_UNCOMMITTED:
                $sql = "READ UNCOMMITTED";
                break;
            case SQLSRV_TXN_READ_COMMITTED:
                $sql = "READ COMMITTED";
                break;
            case SQLSRV_TXN_REPEATABLE_READ:
                $sql = "REPEATABLE READ";
                break;
            case SQLSRV_TXN_SNAPSHOT:
                $sql = "SNAPSHOT";
                break;
            case SQLSRV_TXN_SERIALIZABLE:
                $sql = "SERIALIZABLE";
                break;
            default:
                // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
                throw new Zend_Db_Adapter_Sqlsrv_Exception("Invalid transaction isolation level mode '$level' specified");
        }

        if (!sqlsrv_query($this->_connection, "SET TRANSACTION ISOLATION LEVEL $sql;")) {
            // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
            throw new Zend_Db_Adapter_Sqlsrv_Exception("Transaction cannot be changed to '$level'");
        }

        return true;
    }
1373157
@Override
	public void setRollbackOnly() throws TransactionManagementException {
		logger.entering(CLASSNAME, "setRollbackOnly");
		try {
			userTran.setRollbackOnly();
			logger.log(Level.FINE, "javax.transaction.Status: {0}", userTran.getStatus());
		} catch (IllegalStateException e) {
			throw new TransactionManagementException(e);
		} catch (SystemException e) {
			throw new TransactionManagementException(e);
		}
		logger.exiting(CLASSNAME, "setRollbackOnly");
	}
1287201
private void setConsistencylevel(Object value)
    {
        if (value instanceof String)
        {
            this.cassandraClientBase.setConsistencyLevel(ConsistencyLevel.valueOf((String) value));
        }
        else if (value instanceof ConsistencyLevel)
        {
            this.cassandraClientBase.setConsistencyLevel((ConsistencyLevel) value);
        }

    }