當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。