本文整理汇总了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()));
}
}
示例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();
}
}
示例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();
}
示例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];
}
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}