Java Code Examples for java.sql.Connection#TRANSACTION_READ_UNCOMMITTED

The following examples show how to use java.sql.Connection#TRANSACTION_READ_UNCOMMITTED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GFXDPrms.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static String getTxIsolation(int n) {
  switch (n) {
    case TRANSACTION_NONE:
         return "none";
    case Connection.TRANSACTION_READ_UNCOMMITTED:
         return "read_uncommitted";
    case Connection.TRANSACTION_READ_COMMITTED:
         return "read_committed";
    case Connection.TRANSACTION_REPEATABLE_READ:
         return "repeatable_read";
    case Connection.TRANSACTION_SERIALIZABLE:
         return "serializable";
    default:
      String s = "Unknown transaction isolation level: " + n;
      throw new HydraConfigException(s);
  }
}
 
Example 2
Source File: Converters.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static byte getThriftTransactionIsolation(int jdbcIsolationLevel) {
  switch (jdbcIsolationLevel) {
    case Connection.TRANSACTION_NONE:
      return gfxdConstants.TRANSACTION_NONE;
    case Connection.TRANSACTION_READ_UNCOMMITTED:
      return gfxdConstants.TRANSACTION_READ_UNCOMMITTED;
    case Connection.TRANSACTION_READ_COMMITTED:
      return gfxdConstants.TRANSACTION_READ_COMMITTED;
    case Connection.TRANSACTION_REPEATABLE_READ:
      return gfxdConstants.TRANSACTION_REPEATABLE_READ;
    case Connection.TRANSACTION_SERIALIZABLE:
      return gfxdConstants.TRANSACTION_SERIALIZABLE;
    default:
      return gfxdConstants.TRANSACTION_NO_CHANGE;
  }
}
 
Example 3
Source File: QueryPerfPrms.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static String getTxIsolation(int n) {
  switch (n) {
    case TRANSACTION_NONE:
         return "none";
    case Connection.TRANSACTION_READ_UNCOMMITTED:
         return "transaction_read_uncommitted";
    case Connection.TRANSACTION_READ_COMMITTED:
         return "transaction_read_committed";
    case Connection.TRANSACTION_REPEATABLE_READ:
         return "transaction_repeatable_read";
    case Connection.TRANSACTION_SERIALIZABLE:
         return "transaction_serializable";
    default:
      String s = "Unknown transaction isolation level: " + n;
      throw new QueryPerfException(s);
  }
}
 
Example 4
Source File: ACIDReadModifyWriteDefaultIsolationLevelTest.java    From high-performance-java-persistence with Apache License 2.0 6 votes vote down vote up
private void printIsolationLevel(Connection connection) throws SQLException {
    int isolationLevelIntegerValue = connection.getTransactionIsolation();

    String isolationLevelStringValue = null;

    switch (isolationLevelIntegerValue) {
        case Connection.TRANSACTION_READ_UNCOMMITTED:
            isolationLevelStringValue = "READ_UNCOMMITTE";
            break;
        case Connection.TRANSACTION_READ_COMMITTED:
            isolationLevelStringValue = "READ_COMMITTED";
            break;
        case Connection.TRANSACTION_REPEATABLE_READ:
            isolationLevelStringValue = "REPEATABLE_READ";
            break;
        case Connection.TRANSACTION_SERIALIZABLE:
            isolationLevelStringValue = "SERIALIZABLE";
            break;
    }

    LOGGER.info("Transaction isolation level: {}", isolationLevelStringValue);
}
 
Example 5
Source File: Converters.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static byte getThriftTransactionIsolation(int jdbcIsolationLevel) {
  switch (jdbcIsolationLevel) {
    case Connection.TRANSACTION_NONE:
      return gfxdConstants.TRANSACTION_NONE;
    case Connection.TRANSACTION_READ_UNCOMMITTED:
      return gfxdConstants.TRANSACTION_READ_UNCOMMITTED;
    case Connection.TRANSACTION_READ_COMMITTED:
      return gfxdConstants.TRANSACTION_READ_COMMITTED;
    case Connection.TRANSACTION_REPEATABLE_READ:
      return gfxdConstants.TRANSACTION_REPEATABLE_READ;
    case Connection.TRANSACTION_SERIALIZABLE:
      return gfxdConstants.TRANSACTION_SERIALIZABLE;
    default:
      return gfxdConstants.TRANSACTION_NO_CHANGE;
  }
}
 
Example 6
Source File: FBTpbMapper.java    From jaybird with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Convert transaction isolation level name into a corresponding constant.
 *
 * @param isolationName
 *         name of the transaction isolation.
 * @return corresponding constant.
 */
public static int getTransactionIsolationLevel(String isolationName) {
    switch (isolationName) {
    case TRANSACTION_NONE:
        return Connection.TRANSACTION_NONE;
    case TRANSACTION_READ_UNCOMMITTED:
        return Connection.TRANSACTION_READ_UNCOMMITTED;
    case TRANSACTION_READ_COMMITTED:
        return Connection.TRANSACTION_READ_COMMITTED;
    case TRANSACTION_REPEATABLE_READ:
        return Connection.TRANSACTION_REPEATABLE_READ;
    case TRANSACTION_SERIALIZABLE:
        return Connection.TRANSACTION_SERIALIZABLE;
    default:
        throw new IllegalArgumentException("Invalid isolation name.");
    }
}
 
Example 7
Source File: TransactionUtil.java    From aceql-http with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static String getTransactionIsolationAsString(
    int transactionIsolationLevel) {

if (transactionIsolationLevel == Connection.TRANSACTION_NONE) {
    return HttpParameter.NONE;
} else if (transactionIsolationLevel == Connection.TRANSACTION_READ_UNCOMMITTED) {
    return HttpParameter.READ_UNCOMMITTED;
} else if (transactionIsolationLevel == Connection.TRANSACTION_READ_COMMITTED) {
    return HttpParameter.READ_COMMITTED;
} else if (transactionIsolationLevel == Connection.TRANSACTION_REPEATABLE_READ) {
    return HttpParameter.REPEATABLE_READ;
} else if (transactionIsolationLevel == Connection.TRANSACTION_SERIALIZABLE) {
    return HttpParameter.SERIALIZABLE;
} else {
    return "UNKNOWN";
}
   }
 
Example 8
Source File: GFXDPrms.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private static int getTxIsolation(Long key, String val) {
  if (val.equalsIgnoreCase("none")) {
    return TRANSACTION_NONE;
  }
  else {
    if (val.equalsIgnoreCase("read_uncommitted") ||
        val.equalsIgnoreCase("readUncommitted")) {
      return Connection.TRANSACTION_READ_UNCOMMITTED;
    }
    else if (val.equalsIgnoreCase("read_committed") ||
             val.equalsIgnoreCase("readCommitted")) {
      return Connection.TRANSACTION_READ_COMMITTED;
    }
    else if (val.equalsIgnoreCase("repeatable_read") ||
             val.equalsIgnoreCase("repeatableRead")) {
      return Connection.TRANSACTION_REPEATABLE_READ;
    }
    else if (val.equalsIgnoreCase("serializable")) {
      return Connection.TRANSACTION_SERIALIZABLE;
    }
    else {
      String s = "Illegal value for " + BasePrms.nameForKey(key) + ": " + val;
      throw new HydraConfigException(s);
    }
  }
}
 
Example 9
Source File: CommonRowSetTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "rowSetIsolationTypes")
protected Object[][] rowSetIsolationTypes() throws Exception {
    RowSet rs = newInstance();

    return new Object[][]{
        {rs, Connection.TRANSACTION_NONE},
        {rs, Connection.TRANSACTION_READ_COMMITTED},
        {rs, Connection.TRANSACTION_READ_UNCOMMITTED},
        {rs, Connection.TRANSACTION_REPEATABLE_READ},
        {rs, Connection.TRANSACTION_SERIALIZABLE}
    };
}
 
Example 10
Source File: DatabaseStatusChecker.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
private String getIsolation(int i) {
    if (i == Connection.TRANSACTION_READ_COMMITTED) {
        return "READ_COMMITTED";
    }
    if (i == Connection.TRANSACTION_READ_UNCOMMITTED) {
        return "READ_UNCOMMITTED";
    }
    if (i == Connection.TRANSACTION_REPEATABLE_READ) {
        return "REPEATABLE_READ";
    }
    if (i == Connection.TRANSACTION_SERIALIZABLE) {
        return "SERIALIZABLE)";
    }
    return "NONE";
}
 
Example 11
Source File: RuntimeStatisticsParser.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Create a RuntimeStatistics object to parse the text and extract
 * information.
 * 
 * @param rts
 *            Runtime Statistics string
 * 
 */
public RuntimeStatisticsParser(String rts) {
	statistics = rts;
    if (rts.indexOf(" at serializable isolation level ") != -1)
        isolationLevel = Connection.TRANSACTION_SERIALIZABLE;
    else if (rts.indexOf("at read uncommitted isolation level") != -1)
        isolationLevel = Connection.TRANSACTION_READ_UNCOMMITTED;
    else if (rts.indexOf("at read committed isolation level") != -1)
        isolationLevel = Connection.TRANSACTION_READ_COMMITTED;
    else if (rts.indexOf("at repeatable read isolation level") != -1)
        isolationLevel = Connection.TRANSACTION_REPEATABLE_READ;

    if (rts.indexOf("Distinct Scan ResultSet") > 0) {
    	distinctScan = true;
    }
    
    if (rts.indexOf("Table Scan ResultSet") > 0) {
    	tableScan = true;
    }

    indexScan = (rts.indexOf("Index Scan ResultSet") >= 0);
    indexRowToBaseRow =
        (rts.indexOf("Index Row to Base Row ResultSet") >= 0);
    
    if (rts.indexOf("Eliminate duplicates = true") > 0) {
    	eliminatedDuplicates = true;
    }
    if (rts.indexOf("Scroll Insensitive ResultSet:") > 0)
        scrollInsensitive = true;

    qualifiers = findQualifiers();
}
 
Example 12
Source File: RuntimeStatisticsParser.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Create a RuntimeStatistics object to parse the text and extract
 * information.
 * 
 * @param rts
 *            Runtime Statistics string
 * 
 */
public RuntimeStatisticsParser(String rts) {
	statistics = rts;
    if (rts.indexOf(" at serializable isolation level ") != -1)
        isolationLevel = Connection.TRANSACTION_SERIALIZABLE;
    else if (rts.indexOf("at read uncommitted isolation level") != -1)
        isolationLevel = Connection.TRANSACTION_READ_UNCOMMITTED;
    else if (rts.indexOf("at read committed isolation level") != -1)
        isolationLevel = Connection.TRANSACTION_READ_COMMITTED;
    else if (rts.indexOf("at repeatable read isolation level") != -1)
        isolationLevel = Connection.TRANSACTION_REPEATABLE_READ;

    if (rts.indexOf("Distinct Scan ResultSet") > 0) {
    	distinctScan = true;
    }
    
    if (rts.indexOf("Table Scan ResultSet") > 0) {
    	tableScan = true;
    }

    indexScan = (rts.indexOf("Index Scan ResultSet") >= 0);
    indexRowToBaseRow =
        (rts.indexOf("Index Row to Base Row ResultSet") >= 0);
    lastKeyIndexScan = (rts.indexOf("Last Key Index Scan ResultSet") >= 0);
    
    if (rts.indexOf("Eliminate duplicates = true") > 0) {
    	eliminatedDuplicates = true;
    }
    if (rts.indexOf("Scroll Insensitive ResultSet:") > 0)
        scrollInsensitive = true;

    qualifiers = findQualifiers();
    
    startPosition = getStartPosition();
    stopPosition = getStopPosition();
}
 
Example 13
Source File: DatabaseStatusChecker.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private String getIsolation(int i) {
    if (i == Connection.TRANSACTION_READ_COMMITTED) {
        return "READ_COMMITTED";
    }
    if (i == Connection.TRANSACTION_READ_UNCOMMITTED) {
        return "READ_UNCOMMITTED";
    }
    if (i == Connection.TRANSACTION_REPEATABLE_READ) {
        return "REPEATABLE_READ";
    }
    if (i == Connection.TRANSACTION_SERIALIZABLE) {
        return "SERIALIZABLE)";
    }
    return "NONE";
}
 
Example 14
Source File: CommonRowSetTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "rowSetIsolationTypes")
protected Object[][] rowSetIsolationTypes() throws Exception {
    RowSet rs = newInstance();

    return new Object[][]{
        {rs, Connection.TRANSACTION_NONE},
        {rs, Connection.TRANSACTION_READ_COMMITTED},
        {rs, Connection.TRANSACTION_READ_UNCOMMITTED},
        {rs, Connection.TRANSACTION_REPEATABLE_READ},
        {rs, Connection.TRANSACTION_SERIALIZABLE}
    };
}
 
Example 15
Source File: InstanceKeyDataSource.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Sets the value of defaultTransactionIsolation, which defines the state of connections handed out from this pool.
 * The value can be changed on the Connection using Connection.setTransactionIsolation(int). The default is JDBC
 * driver dependent.
 *
 * @param v
 *            Value to assign to defaultTransactionIsolation
 */
public void setDefaultTransactionIsolation(final int v) {
    assertInitializationAllowed();
    switch (v) {
    case Connection.TRANSACTION_NONE:
    case Connection.TRANSACTION_READ_COMMITTED:
    case Connection.TRANSACTION_READ_UNCOMMITTED:
    case Connection.TRANSACTION_REPEATABLE_READ:
    case Connection.TRANSACTION_SERIALIZABLE:
        break;
    default:
        throw new IllegalArgumentException(BAD_TRANSACTION_ISOLATION);
    }
    this.defaultTransactionIsolation = v;
}
 
Example 16
Source File: CommonRowSetTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "rowSetIsolationTypes")
protected Object[][] rowSetIsolationTypes() throws Exception {
    RowSet rs = newInstance();

    return new Object[][]{
        {rs, Connection.TRANSACTION_NONE},
        {rs, Connection.TRANSACTION_READ_COMMITTED},
        {rs, Connection.TRANSACTION_READ_UNCOMMITTED},
        {rs, Connection.TRANSACTION_REPEATABLE_READ},
        {rs, Connection.TRANSACTION_SERIALIZABLE}
    };
}
 
Example 17
Source File: QueryPerfPrms.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private static int getTxIsolation(Long key, String val) {
  if (val.equalsIgnoreCase("transaction_none") ||
      val.equalsIgnoreCase("transactionNone") ||
      val.equalsIgnoreCase("none")) {
    return TRANSACTION_NONE;
  }
  else {
    if (val.equalsIgnoreCase("transaction_read_uncommitted") ||
        val.equalsIgnoreCase("transactionReadUncommitted") ||
        val.equalsIgnoreCase("read_uncommitted") ||
        val.equalsIgnoreCase("readUncommitted")) {
      return Connection.TRANSACTION_READ_UNCOMMITTED;
    }
    else if (val.equalsIgnoreCase("transaction_read_committed") ||
             val.equalsIgnoreCase("transactionReadCommitted") ||
             val.equalsIgnoreCase("read_committed") ||
             val.equalsIgnoreCase("readCommitted")) {
      return Connection.TRANSACTION_READ_COMMITTED;
    }
    else if (val.equalsIgnoreCase("transaction_repeatable_read") ||
             val.equalsIgnoreCase("transactionRepeatableRead") ||
             val.equalsIgnoreCase("repeatable_read") ||
             val.equalsIgnoreCase("repeatableRead")) {
      return Connection.TRANSACTION_REPEATABLE_READ;
    }
    else if (val.equalsIgnoreCase("transaction_serializable") ||
             val.equalsIgnoreCase("transactionSerializable") ||
             val.equalsIgnoreCase("serializable")) {
      return Connection.TRANSACTION_SERIALIZABLE;
    }
    else {
      String s = "Illegal value for " + BasePrms.nameForKey(key) + ": " + val;
      throw new HydraConfigException(s);
    }
  }
}
 
Example 18
Source File: CommonRowSetTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "rowSetIsolationTypes")
protected Object[][] rowSetIsolationTypes() throws Exception {
    RowSet rs = newInstance();

    return new Object[][]{
        {rs, Connection.TRANSACTION_NONE},
        {rs, Connection.TRANSACTION_READ_COMMITTED},
        {rs, Connection.TRANSACTION_READ_UNCOMMITTED},
        {rs, Connection.TRANSACTION_REPEATABLE_READ},
        {rs, Connection.TRANSACTION_SERIALIZABLE}
    };
}
 
Example 19
Source File: MSAccessConnection.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected void optimizeConnection(OperationType operationType) throws Exception {
	switch (operationType) {
	case READ:
		connection.setAutoCommit(false);
		connection.setReadOnly(true);
		break;
	case WRITE:
	case CALL:
		connection.setAutoCommit(false);
		connection.setReadOnly(false);
		break;

	case TRANSACTION:
		connection.setAutoCommit(true);
		connection.setReadOnly(false);
		break;
	}
	
	//it's not possible to set transaction isolation level
	//log the message about it
	String transactionIsolationLevel = "";
	switch (connection.getTransactionIsolation()) {
	case Connection.TRANSACTION_NONE:
		transactionIsolationLevel = "TRANSACTION_NONE";
		break;
	case Connection.TRANSACTION_READ_COMMITTED:
		transactionIsolationLevel = "TRANSACTION_READ_COMMITTED";
		break;
	case Connection.TRANSACTION_READ_UNCOMMITTED:
		transactionIsolationLevel = "TRANSACTION_READ_UNCOMMITTED";
		break;
	case Connection.TRANSACTION_REPEATABLE_READ:
		transactionIsolationLevel = "TRANSACTION_REPEATABLE_READ";
		break;
	case Connection.TRANSACTION_SERIALIZABLE:
		transactionIsolationLevel = "TRANSACTION_SERIALIZABLE";
		break;
	}
	logger.warn("Transaction isolation level is set to " + transactionIsolationLevel + " and cannot be changed.");
}
 
Example 20
Source File: PrestoDatabaseMetaData.java    From presto with Apache License 2.0 4 votes vote down vote up
@Override
public int getDefaultTransactionIsolation()
        throws SQLException
{
    return Connection.TRANSACTION_READ_UNCOMMITTED;
}