java.sql.Connection#TRANSACTION_READ_COMMITTED源码实例Demo

下面列出了java.sql.Connection#TRANSACTION_READ_COMMITTED 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gemfirexd-oss   文件: J2EEDataSourceTest.java
private void assertIsoLocks(Connection conn, int expectedIsoLevel)
throws SQLException {
    int conniso = conn.getTransactionIsolation();
    assertEquals(expectedIsoLevel, conniso);

    boolean selectTimedOut = selectTimesoutDuringUpdate(conn);
    // expect a lock timeout for READ_COMMITTED
    switch (conniso) {
        case Connection.TRANSACTION_READ_UNCOMMITTED:
            assertFalse(selectTimedOut); break;
        case Connection.TRANSACTION_READ_COMMITTED:
            assertTrue(selectTimedOut); break;
        default:
            System.out.println("No test support for isolation level");
    }
}
 
源代码2 项目: gemfirexd-oss   文件: Converters.java
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;
  }
}
 
源代码3 项目: gemfirexd-oss   文件: GFXDPrms.java
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);
    }
  }
}
 
@Override
public boolean supportsTransactionIsolationLevel(int level)
throws SQLException
{
  logger.debug(
      "public boolean supportsTransactionIsolationLevel(int level)");
  raiseSQLExceptionIfConnectionIsClosed();
  return (level == Connection.TRANSACTION_NONE)
         || (level == Connection.TRANSACTION_READ_COMMITTED);
}
 
源代码5 项目: micro-integrator   文件: JDBCUserStoreManager.java
/**
 * @return
 * @throws SQLException
 * @throws UserStoreException
 */
protected Connection getDBConnection() throws SQLException, UserStoreException {
    Connection dbConnection = getJDBCDataSource().getConnection();
    dbConnection.setAutoCommit(false);
    if (dbConnection.getTransactionIsolation() != Connection.TRANSACTION_READ_COMMITTED) {
        dbConnection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
    }
    return dbConnection;
}
 
源代码6 项目: gemfirexd-oss   文件: QueryPerfPrms.java
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);
    }
  }
}
 
源代码7 项目: TencentKona-8   文件: CommonRowSetTests.java
@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}
    };
}
 
源代码8 项目: dubbox   文件: DatabaseStatusChecker.java
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";
}
 
源代码9 项目: jqm   文件: Db.java
/**
 * A connection to the database. Should be short-lived. No transaction active by default.
 *
 * @return a new open connection.
 */
public DbConn getConn()
{
    Connection cnx = null;
    try
    {
        Thread.interrupted(); // this is VERY sad. Needed for Oracle driver which otherwise fails spectacularly.
        cnx = _ds.getConnection();
        if (cnx.getAutoCommit())
        {
            cnx.setAutoCommit(false);
            cnx.rollback(); // To ensure no open transaction created by the pool before changing TX mode
        }

        if (cnx.getTransactionIsolation() != Connection.TRANSACTION_READ_COMMITTED)
        {
            cnx.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
        }

        return new DbConn(this, cnx);
    }
    catch (SQLException e)
    {
        DbHelper.closeQuietly(cnx); // May have been left open when the pool has given us a failed connection.
        throw new DatabaseException(e);
    }
}
 
源代码10 项目: aceql-http   文件: TransactionUtil.java
private static int getTransactionIsolation(String actionValue) {

	if (actionValue.equals(HttpParameter.READ_UNCOMMITTED)) {
	    return Connection.TRANSACTION_READ_UNCOMMITTED;
	} else if (actionValue.equals(HttpParameter.READ_COMMITTED)) {
	    return Connection.TRANSACTION_READ_COMMITTED;
	} else if (actionValue.equals(HttpParameter.REPEATABLE_READ)) {
	    return Connection.TRANSACTION_REPEATABLE_READ;
	} else if (actionValue.equals(HttpParameter.SERIALIZABLE)) {
	    return Connection.TRANSACTION_SERIALIZABLE;
	} else {
	    throw new IllegalArgumentException(
		    "Unsupported Transaction Isolation Level: " + actionValue);
	}
    }
 
源代码11 项目: vertx-sql-client   文件: DRDAConnectResponse.java
/**
    * Parse the initial PBSD - PiggyBackedSessionData code point.
    * <p>
    * If sent by the server, it contains a PBSD_ISO code point followed by a
    * byte representing the JDBC isolation level, and a PBSD_SCHEMA code point
    * followed by the name of the current schema as an UTF-8 String.
    */
   private void parseInitialPBSD() {
       if (peekCodePoint() != CodePoint.PBSD) {
           return;
       }
       parseLengthAndMatchCodePoint(CodePoint.PBSD);
       int peekCP = peekCodePoint();
       while (peekCP != END_OF_SAME_ID_CHAIN) {
           parseLengthAndMatchCodePoint(peekCP);
           switch (peekCP) {
               case CodePoint.PBSD_ISO:
                   int isolationLevel = readUnsignedByte();
                   if (isolationLevel != Connection.TRANSACTION_READ_COMMITTED)
                       throw new IllegalStateException("Database using unsupported transaction isolation level: " + isolationLevel);
//                   netAgent_.netConnection_.
//                       completeInitialPiggyBackIsolation(readUnsignedByte());
                   break;
               case CodePoint.PBSD_SCHEMA:
                   String pbSchema = readString(getDdmLength(), CCSIDConstants.UTF8);
//                   netAgent_.netConnection_.
//                       completeInitialPiggyBackSchema
//                           (readString(getDdmLength(), Typdef.UTF8ENCODING));
                   break;
               default:
                   throw new IllegalStateException("Found unknown codepoint: " + Integer.toHexString(peekCP));
           }
           peekCP = peekCodePoint();
       }
   }
 
源代码12 项目: openjdk-jdk9   文件: CommonRowSetTests.java
@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}
    };
}
 
源代码13 项目: gemfirexd-oss   文件: RuntimeStatisticsParser.java
/**
 * 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();
}
 
源代码14 项目: dubbox   文件: DatabaseStatusChecker.java
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";
}
 
源代码15 项目: dubbox   文件: DatabaseStatusChecker.java
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";
}
 
源代码16 项目: gemfirexd-oss   文件: QueryPerfPrms.java
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);
    }
  }
}
 
源代码17 项目: gemfirexd-oss   文件: OraclePrms.java
public static String getTxIsolation(int n) {
  switch (n) {
    case Connection.TRANSACTION_READ_COMMITTED:
         return "read_committed";
    case Connection.TRANSACTION_SERIALIZABLE:
         return "serializable";
    default:
      String s = "Unknown transaction isolation level: " + n;
      throw new HydraConfigException(s);
  }
}
 
protected int getIsolationLevel() {
  return Connection.TRANSACTION_READ_COMMITTED;
}
 
@Override
public int getIsolationLevel() {
  return Connection.TRANSACTION_READ_COMMITTED;
}
 
源代码20 项目: gemfirexd-oss   文件: SelectForUpdateTest.java
protected int getIsolationLevel() {
  return Connection.TRANSACTION_READ_COMMITTED;
}