当前位置: 首页>>代码示例>>Java>>正文


Java SQLTransactionRollbackException类代码示例

本文整理汇总了Java中java.sql.SQLTransactionRollbackException的典型用法代码示例。如果您正苦于以下问题:Java SQLTransactionRollbackException类的具体用法?Java SQLTransactionRollbackException怎么用?Java SQLTransactionRollbackException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SQLTransactionRollbackException类属于java.sql包,在下文中一共展示了SQLTransactionRollbackException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test11

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using for-each loop
 */
@Test
public void test11() {
    SQLTransactionRollbackException ex =
            new SQLTransactionRollbackException("Exception 1", t1);
    SQLTransactionRollbackException ex1 =
            new SQLTransactionRollbackException("Exception 2");
    SQLTransactionRollbackException ex2 =
            new SQLTransactionRollbackException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:SQLTransactionRollbackExceptionTests.java

示例2: test12

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLTransactionRollbackException ex =
            new SQLTransactionRollbackException("Exception 1", t1);
    SQLTransactionRollbackException ex1 =
            new SQLTransactionRollbackException("Exception 2");
    SQLTransactionRollbackException ex2 =
            new SQLTransactionRollbackException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:SQLTransactionRollbackExceptionTests.java

示例3: testTimeout

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
public void testTimeout() throws SQLException {
    Connection con1 = openDefaultConnection();
    Connection con2 = openDefaultConnection();
    con1.setAutoCommit(false);
    con2.setAutoCommit(false);
    con1.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
    con2.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
    con1.createStatement().execute(
        "select * from EXCEPTION_TABLE1 for update");
    try {
        con2.createStatement().execute(
            "select * from EXCEPTION_TABLE1 for update");
        fail("Statement didn't fail.");
    } catch (SQLTransactionRollbackException e) {
        assertTrue("Unexpected SQL State: " + e.getSQLState(),
                   e.getSQLState().startsWith("40"));
    }
    con1.rollback();
    con1.close();
    con2.rollback();
    con2.close();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:TestJDBC40Exception.java

示例4: loadClustersForClusterSet

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
@Override
public Cluster[] loadClustersForClusterSet(ClusterSet cs) throws SQLException {
    PreparedStatement st = con.prepareStatement("select distinct id from vss.clusters where cs_id = ?");
    st.setInt(1, cs.getID());
    List<Cluster> list;
    try (ResultSet rs = st.executeQuery()) {
        list = new LinkedList<>();
        while (rs.next()) {
            list.add(loadCluster(rs.getInt(1), cs));
        }

        Collections.sort(list, new Comparator<Cluster>() {
            @Override
            public int compare(Cluster o1, Cluster o2) {
                return o2.size() - o1.size();
            }
        });

        return list.toArray(new Cluster[list.size()]);
    } catch (SQLTransactionRollbackException e) {
        logger.showException(e);
        return new Cluster[0];
    }

}
 
开发者ID:nolanlab,项目名称:vortex,代码行数:26,代码来源:HSQLDBStorageEngine2.java

示例5: test_Constructor_LStringLString

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
/**
 * @test java.sql.SQLTransactionRollbackException(String, String)
 */
public void test_Constructor_LStringLString() {
    SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException(
            "MYTESTSTRING1", "MYTESTSTRING2");
    assertNotNull(sQLTransactionRollbackException);
    assertEquals(
            "The SQLState of SQLTransactionRollbackException set and get should be equivalent",
            "MYTESTSTRING2", sQLTransactionRollbackException.getSQLState());
    assertEquals(
            "The reason of SQLTransactionRollbackException set and get should be equivalent",
            "MYTESTSTRING1", sQLTransactionRollbackException.getMessage());
    assertEquals(
            "The error code of SQLTransactionRollbackException should be 0",
            sQLTransactionRollbackException.getErrorCode(), 0);

}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:SQLTransactionRollbackExceptionTest.java

示例6: test_Constructor_LThrowable

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
/**
 * @test java.sql.SQLTransactionRollbackException(Throwable)
 */
public void test_Constructor_LThrowable() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException(
            cause);
    assertNotNull(sQLTransactionRollbackException);
    assertEquals(
            "The reason of SQLTransactionRollbackException should be equals to cause.toString()",
            "java.lang.Exception: MYTHROWABLE",
            sQLTransactionRollbackException.getMessage());
    assertNull(
            "The SQLState of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getSQLState());
    assertEquals(
            "The error code of SQLTransactionRollbackException should be 0",
            sQLTransactionRollbackException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransactionRollbackException set and get should be equivalent",
            cause, sQLTransactionRollbackException.getCause());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:SQLTransactionRollbackExceptionTest.java

示例7: test_Constructor_LThrowable_1

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
/**
 * @test java.sql.SQLTransactionRollbackException(Throwable)
 */
public void test_Constructor_LThrowable_1() {
    SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException(
            (Throwable) null);
    assertNotNull(sQLTransactionRollbackException);
    assertNull(
            "The SQLState of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getSQLState());
    assertNull(
            "The reason of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getMessage());
    assertEquals(
            "The error code of SQLTransactionRollbackException should be 0",
            sQLTransactionRollbackException.getErrorCode(), 0);
    assertNull(
            "The cause of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getCause());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:SQLTransactionRollbackExceptionTest.java

示例8: test_Constructor_LStringLThrowable

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
/**
 * @test java.sql.SQLTransactionRollbackException(String, Throwable)
 */
public void test_Constructor_LStringLThrowable() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException(
            "MYTESTSTRING", cause);
    assertNotNull(sQLTransactionRollbackException);
    assertEquals(
            "The reason of SQLTransactionRollbackException set and get should be equivalent",
            "MYTESTSTRING", sQLTransactionRollbackException.getMessage());
    assertNull(
            "The SQLState of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getSQLState());
    assertEquals(
            "The error code of SQLTransactionRollbackException should be 0",
            sQLTransactionRollbackException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransactionRollbackException set and get should be equivalent",
            cause, sQLTransactionRollbackException.getCause());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:SQLTransactionRollbackExceptionTest.java

示例9: test_Constructor_LStringLThrowable_1

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
/**
 * @test java.sql.SQLTransactionRollbackException(String, Throwable)
 */
public void test_Constructor_LStringLThrowable_1() {
    SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException(
            "MYTESTSTRING", (Throwable) null);
    assertNotNull(sQLTransactionRollbackException);
    assertEquals(
            "The reason of SQLTransactionRollbackException set and get should be equivalent",
            "MYTESTSTRING", sQLTransactionRollbackException.getMessage());
    assertNull(
            "The SQLState of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getSQLState());
    assertEquals(
            "The error code of SQLTransactionRollbackException should be 0",
            sQLTransactionRollbackException.getErrorCode(), 0);
    assertNull(
            "The cause of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getCause());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:SQLTransactionRollbackExceptionTest.java

示例10: test_Constructor_LStringLThrowable_2

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
/**
 * @test java.sql.SQLTransactionRollbackException(String, Throwable)
 */
public void test_Constructor_LStringLThrowable_2() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException(
            null, cause);
    assertNotNull(sQLTransactionRollbackException);
    assertNull(
            "The reason of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getMessage());
    assertNull(
            "The SQLState of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getSQLState());
    assertEquals(
            "The error code of SQLTransactionRollbackException should be 0",
            sQLTransactionRollbackException.getErrorCode(), 0);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:SQLTransactionRollbackExceptionTest.java

示例11: test_Constructor_LStringLThrowable_3

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
/**
 * @test java.sql.SQLTransactionRollbackException(String, Throwable)
 */
public void test_Constructor_LStringLThrowable_3() {
    SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException(
            (String) null, (Throwable) null);
    assertNotNull(sQLTransactionRollbackException);
    assertNull(
            "The SQLState of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getSQLState());
    assertNull(
            "The reason of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getMessage());
    assertEquals(
            "The error code of SQLTransactionRollbackException should be 0",
            sQLTransactionRollbackException.getErrorCode(), 0);
    assertNull(
            "The cause of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getCause());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:SQLTransactionRollbackExceptionTest.java

示例12: test_Constructor_LStringLStringLThrowable

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
/**
 * @test java.sql.SQLTransactionRollbackException(String, String, Throwable)
 */
public void test_Constructor_LStringLStringLThrowable() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException(
            "MYTESTSTRING1", "MYTESTSTRING2", cause);
    assertNotNull(sQLTransactionRollbackException);
    assertEquals(
            "The SQLState of SQLTransactionRollbackException set and get should be equivalent",
            "MYTESTSTRING2", sQLTransactionRollbackException.getSQLState());
    assertEquals(
            "The reason of SQLTransactionRollbackException set and get should be equivalent",
            "MYTESTSTRING1", sQLTransactionRollbackException.getMessage());
    assertEquals(
            "The error code of SQLTransactionRollbackException should be 0",
            sQLTransactionRollbackException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransactionRollbackException set and get should be equivalent",
            cause, sQLTransactionRollbackException.getCause());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:SQLTransactionRollbackExceptionTest.java

示例13: test_Constructor_LStringLStringLThrowable_1

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
/**
 * @test java.sql.SQLTransactionRollbackException(String, String, Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_1() {
    SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException(
            "MYTESTSTRING1", "MYTESTSTRING2", null);
    assertNotNull(sQLTransactionRollbackException);
    assertEquals(
            "The SQLState of SQLTransactionRollbackException set and get should be equivalent",
            "MYTESTSTRING2", sQLTransactionRollbackException.getSQLState());
    assertEquals(
            "The reason of SQLTransactionRollbackException set and get should be equivalent",
            "MYTESTSTRING1", sQLTransactionRollbackException.getMessage());
    assertEquals(
            "The error code of SQLTransactionRollbackException should be 0",
            sQLTransactionRollbackException.getErrorCode(), 0);
    assertNull(
            "The cause of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getCause());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:SQLTransactionRollbackExceptionTest.java

示例14: test_Constructor_LStringLStringLThrowable_2

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
/**
 * @test java.sql.SQLTransactionRollbackException(String, String, Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_2() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException(
            "MYTESTSTRING", null, cause);
    assertNotNull(sQLTransactionRollbackException);
    assertNull(
            "The SQLState of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getSQLState());
    assertEquals(
            "The reason of SQLTransactionRollbackException set and get should be equivalent",
            "MYTESTSTRING", sQLTransactionRollbackException.getMessage());
    assertEquals(
            "The error code of SQLTransactionRollbackException should be 0",
            sQLTransactionRollbackException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransactionRollbackException set and get should be equivalent",
            cause, sQLTransactionRollbackException.getCause());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:SQLTransactionRollbackExceptionTest.java

示例15: test_Constructor_LStringLStringLThrowable_3

import java.sql.SQLTransactionRollbackException; //导入依赖的package包/类
/**
 * @test java.sql.SQLTransactionRollbackException(String, String, Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_3() {
    SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException(
            "MYTESTSTRING", null, null);
    assertNotNull(sQLTransactionRollbackException);
    assertNull(
            "The SQLState of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getSQLState());
    assertEquals(
            "The reason of SQLTransactionRollbackException set and get should be equivalent",
            "MYTESTSTRING", sQLTransactionRollbackException.getMessage());
    assertEquals(
            "The error code of SQLTransactionRollbackException should be 0",
            sQLTransactionRollbackException.getErrorCode(), 0);
    assertNull(
            "The cause of SQLTransactionRollbackException should be null",
            sQLTransactionRollbackException.getCause());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:SQLTransactionRollbackExceptionTest.java


注:本文中的java.sql.SQLTransactionRollbackException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。