Java 类java.sql.SQLTransientException 实例源码

项目:jdk8u-jdk    文件:SQLTransientExceptionTests.java   
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLTransientException ex = new SQLTransientException("Exception 1", t1);
    SQLTransientException ex1 = new SQLTransientException("Exception 2");
    SQLTransientException ex2 = new SQLTransientException("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();
    }
}
项目:openjdk-jdk10    文件:SQLTransientExceptionTests.java   
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLTransientException ex = new SQLTransientException("Exception 1", t1);
    SQLTransientException ex1 = new SQLTransientException("Exception 2");
    SQLTransientException ex2 = new SQLTransientException("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();
    }
}
项目:openjdk9    文件:SQLTransientExceptionTests.java   
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLTransientException ex = new SQLTransientException("Exception 1", t1);
    SQLTransientException ex1 = new SQLTransientException("Exception 2");
    SQLTransientException ex2 = new SQLTransientException("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();
    }
}
项目:jdk8u_jdk    文件:SQLTransientExceptionTests.java   
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLTransientException ex = new SQLTransientException("Exception 1", t1);
    SQLTransientException ex1 = new SQLTransientException("Exception 2");
    SQLTransientException ex2 = new SQLTransientException("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();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:SQLTransientExceptionTests.java   
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLTransientException ex = new SQLTransientException("Exception 1", t1);
    SQLTransientException ex1 = new SQLTransientException("Exception 2");
    SQLTransientException ex2 = new SQLTransientException("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();
    }
}
项目:cassandra-jdbc-wrapper    文件:CassandraPreparedStatement.java   
CassandraPreparedStatement(CassandraConnection con,
    String cql,
    int rsType,
    int rsConcurrency,
    int rsHoldability
    ) throws SQLException
{
   super(con,cql,rsType,rsConcurrency,rsHoldability);       

   if (LOG.isTraceEnabled()) LOG.trace("CQL: " + this.cql);
   try
   {
       stmt = this.connection.getSession().prepare(cql); 
       this.statement = new BoundStatement(stmt);          
       batchStatements = Lists.newArrayList();
       count = cql.length() - cql.replace("?", "").length();       
   }
   catch (Exception e)
   {
       throw new SQLTransientException(e);
   }
}
项目:cassandra-jdbc-wrapper    文件:CassandraPreparedStatement.java   
private void doExecute() throws SQLException
{
    if (LOG.isTraceEnabled()) LOG.trace("CQL: " + cql);
    try
    {
        resetResults();
        if (this.connection.debugMode) System.out.println("CQL: "+ cql);     
        if(this.statement.getFetchSize()==0)
                // force paging to avoid timeout and node harm...
                this.statement.setFetchSize(100);
        this.statement.setConsistencyLevel(this.connection.defaultConsistencyLevel);
        for(int i=0; i<this.statement.preparedStatement().getVariables().size(); i++){
            // Set parameters to null if unset
            if(!this.statement.isSet(i)){
                this.statement.setToNull(i);
            }
        }
        currentResultSet = new CassandraResultSet(this, this.connection.getSession().execute(this.statement));
    }
    catch (Exception e)
    {
        throw new SQLTransientException(e);
    }
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(Throwable)
 */
public void test_Constructor_LThrowable() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            cause);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The reason of SQLTransientException should be equals to cause.toString()",
            "java.lang.Exception: MYTHROWABLE", sQLTransientException
                    .getMessage());
    assertNull("The SQLState of SQLTransientException should be null",
            sQLTransientException.getSQLState());
    assertEquals("The error code of SQLTransientException should be 0",
            sQLTransientException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, Throwable)
 */
public void test_Constructor_LStringLThrowable() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING", cause);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING", sQLTransientException.getMessage());
    assertNull("The SQLState of SQLTransientException should be null",
            sQLTransientException.getSQLState());
    assertEquals("The error code of SQLTransientException should be 0",
            sQLTransientException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, Throwable)
 */
public void test_Constructor_LStringLStringLThrowable() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING1", "MYTESTSTRING2", cause);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The SQLState of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING2", sQLTransientException.getSQLState());
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING1", sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 0",
            sQLTransientException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_1() {
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING1", "MYTESTSTRING2", null);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The SQLState of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING2", sQLTransientException.getSQLState());
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING1", sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 0",
            sQLTransientException.getErrorCode(), 0);
    assertNull("The cause of SQLTransientException should be null",
            sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_2() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING", null, cause);
    assertNotNull(sQLTransientException);
    assertNull("The SQLState of SQLTransientException should be null",
            sQLTransientException.getSQLState());
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING", sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 0",
            sQLTransientException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_4() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            null, "MYTESTSTRING", cause);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The SQLState of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING", sQLTransientException.getSQLState());
    assertNull("The reason of SQLTransientException should be null",
            sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 0",
            sQLTransientException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_6() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            null, null, cause);
    assertNotNull(sQLTransientException);
    assertNull("The SQLState of SQLTransientException should be null",
            sQLTransientException.getSQLState());
    assertNull("The reason of SQLTransientException should be null",
            sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 0",
            sQLTransientException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING1", "MYTESTSTRING2", 1, cause);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The SQLState of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING2", sQLTransientException.getSQLState());
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING1", sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 1",
            sQLTransientException.getErrorCode(), 1);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_1() {
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING1", "MYTESTSTRING2", 1, null);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The SQLState of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING2", sQLTransientException.getSQLState());
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING1", sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 1",
            sQLTransientException.getErrorCode(), 1);
    assertNull("The cause of SQLTransientException should be null",
            sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_2() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING1", "MYTESTSTRING2", 0, cause);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The SQLState of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING2", sQLTransientException.getSQLState());
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING1", sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 0",
            sQLTransientException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_3() {
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING1", "MYTESTSTRING2", 0, null);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The SQLState of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING2", sQLTransientException.getSQLState());
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING1", sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 0",
            sQLTransientException.getErrorCode(), 0);
    assertNull("The cause of SQLTransientException should be null",
            sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_4() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING1", "MYTESTSTRING2", -1, cause);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The SQLState of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING2", sQLTransientException.getSQLState());
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING1", sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be -1",
            sQLTransientException.getErrorCode(), -1);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_5() {
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING1", "MYTESTSTRING2", -1, null);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The SQLState of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING2", sQLTransientException.getSQLState());
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING1", sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be -1",
            sQLTransientException.getErrorCode(), -1);
    assertNull("The cause of SQLTransientException should be null",
            sQLTransientException.getCause());

}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_6() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING", null, 1, cause);
    assertNotNull(sQLTransientException);
    assertNull("The SQLState of SQLTransientException should be null",
            sQLTransientException.getSQLState());
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING", sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 1",
            sQLTransientException.getErrorCode(), 1);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_7() {
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING", null, 1, null);
    assertNotNull(sQLTransientException);
    assertNotNull(sQLTransientException);
    assertNull("The SQLState of SQLTransientException should be null",
            sQLTransientException.getSQLState());
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING", sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 1",
            sQLTransientException.getErrorCode(), 1);
    assertNull("The cause of SQLTransientException should be null",
            sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_8() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING", null, 0, cause);
    assertNotNull(sQLTransientException);
    assertNull("The SQLState of SQLTransientException should be null",
            sQLTransientException.getSQLState());
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING", sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 0",
            sQLTransientException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_10() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            "MYTESTSTRING", null, -1, cause);
    assertNotNull(sQLTransientException);
    assertNull("The SQLState of SQLTransientException should be null",
            sQLTransientException.getSQLState());
    assertEquals(
            "The reason of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING", sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be -1",
            sQLTransientException.getErrorCode(), -1);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_12() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            null, "MYTESTSTRING", 1, cause);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The SQLState of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING", sQLTransientException.getSQLState());
    assertNull("The reason of SQLTransientException should be null",
            sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 1",
            sQLTransientException.getErrorCode(), 1);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_14() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            null, "MYTESTSTRING", 0, cause);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The SQLState of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING", sQLTransientException.getSQLState());
    assertNull("The reason of SQLTransientException should be null",
            sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 0",
            sQLTransientException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_15() {
    SQLTransientException sQLTransientException = new SQLTransientException(
            null, "MYTESTSTRING", 0, null);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The SQLState of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING", sQLTransientException.getSQLState());
    assertNull("The reason of SQLTransientException should be null",
            sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 0",
            sQLTransientException.getErrorCode(), 0);
    assertNull("The cause of SQLTransientException should be null",
            sQLTransientException.getCause());

}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_16() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            null, "MYTESTSTRING", -1, cause);
    assertNotNull(sQLTransientException);
    assertEquals(
            "The SQLState of SQLTransientException set and get should be equivalent",
            "MYTESTSTRING", sQLTransientException.getSQLState());
    assertNull("The reason of SQLTransientException should be null",
            sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be -1",
            sQLTransientException.getErrorCode(), -1);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_18() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            null, null, 1, cause);
    assertNotNull(sQLTransientException);
    assertNull("The SQLState of SQLTransientException should be null",
            sQLTransientException.getSQLState());
    assertNull("The reason of SQLTransientException should be null",
            sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 1",
            sQLTransientException.getErrorCode(), 1);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_20() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            null, null, 0, cause);
    assertNotNull(sQLTransientException);
    assertNull("The SQLState of SQLTransientException should be null",
            sQLTransientException.getSQLState());
    assertNull("The reason of SQLTransientException should be null",
            sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be 0",
            sQLTransientException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:cn1    文件:SQLTransientExceptionTest.java   
/**
 * @test java.sql.SQLTransientException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_22() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLTransientException sQLTransientException = new SQLTransientException(
            null, null, -1, cause);
    assertNotNull(sQLTransientException);
    assertNull("The SQLState of SQLTransientException should be null",
            sQLTransientException.getSQLState());
    assertNull("The reason of SQLTransientException should be null",
            sQLTransientException.getMessage());
    assertEquals("The error code of SQLTransientException should be -1",
            sQLTransientException.getErrorCode(), -1);
    assertEquals(
            "The cause of SQLTransientException set and get should be equivalent",
            cause, sQLTransientException.getCause());
}
项目:java-retry    文件:SqlTransientExceptionDetector.java   
@Override
public boolean isTransient(Exception e) {
    if (e instanceof SQLTransientException || e instanceof SQLRecoverableException) {
        return true;
    }
    if (e instanceof SQLNonTransientException) {
        return false;
    }
    if (e instanceof SQLException) {
        SQLException se = (SQLException) e;
        if (isSqlStateConnectionException(se) || isSqlStateRollbackException(se)) {
            return true;
        }
        if (isSqlStateDuplicateValueInUniqueIndex(se) && treatDuplicatesAsTransient) {
            return true;
        }
    }
    return false;
}
项目:the-vigilantes    文件:ConnectionRegressionTest.java   
/**
 * Tests fix for Bug#16634180 - LOCK WAIT TIMEOUT EXCEEDED CAUSES SQLEXCEPTION, SHOULD CAUSE SQLTRANSIENTEXCEPTION
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug16634180() throws Exception {

    createTable("testBug16634180", "(pk integer primary key, val integer)", "InnoDB");
    this.stmt.executeUpdate("insert into testBug16634180 values(0,0)");

    Connection c1 = null;
    Connection c2 = null;

    try {
        c1 = getConnectionWithProps(new Properties());
        c1.setAutoCommit(false);
        Statement s1 = c1.createStatement();
        s1.executeUpdate("update testBug16634180 set val=val+1 where pk=0");

        c2 = getConnectionWithProps(new Properties());
        c2.setAutoCommit(false);
        Statement s2 = c2.createStatement();
        try {
            s2.executeUpdate("update testBug16634180 set val=val+1 where pk=0");
            fail("ER_LOCK_WAIT_TIMEOUT should be thrown.");
        } catch (SQLTransientException ex) {
            assertEquals(MysqlErrorNumbers.ER_LOCK_WAIT_TIMEOUT, ex.getErrorCode());
            assertEquals(SQLError.SQL_STATE_ROLLBACK_SERIALIZATION_FAILURE, ex.getSQLState());
            assertEquals("Lock wait timeout exceeded; try restarting transaction", ex.getMessage());
        }
    } finally {
        if (c1 != null) {
            c1.close();
        }
        if (c2 != null) {
            c2.close();
        }
    }
}
项目:OpenVertretung    文件:ConnectionRegressionTest.java   
/**
 * Tests fix for Bug#16634180 - LOCK WAIT TIMEOUT EXCEEDED CAUSES SQLEXCEPTION, SHOULD CAUSE SQLTRANSIENTEXCEPTION
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug16634180() throws Exception {

    createTable("testBug16634180", "(pk integer primary key, val integer)", "InnoDB");
    this.stmt.executeUpdate("insert into testBug16634180 values(0,0)");

    Connection c1 = null;
    Connection c2 = null;

    try {
        c1 = getConnectionWithProps(new Properties());
        c1.setAutoCommit(false);
        Statement s1 = c1.createStatement();
        s1.executeUpdate("update testBug16634180 set val=val+1 where pk=0");

        c2 = getConnectionWithProps(new Properties());
        c2.setAutoCommit(false);
        Statement s2 = c2.createStatement();
        try {
            s2.executeUpdate("update testBug16634180 set val=val+1 where pk=0");
            fail("ER_LOCK_WAIT_TIMEOUT should be thrown.");
        } catch (SQLTransientException ex) {
            assertEquals(MysqlErrorNumbers.ER_LOCK_WAIT_TIMEOUT, ex.getErrorCode());
            assertEquals(SQLError.SQL_STATE_ROLLBACK_SERIALIZATION_FAILURE, ex.getSQLState());
            assertEquals("Lock wait timeout exceeded; try restarting transaction", ex.getMessage());
        }
    } finally {
        if (c1 != null) {
            c1.close();
        }
        if (c2 != null) {
            c2.close();
        }
    }
}
项目:lams    文件:SQLExceptionSubclassTranslator.java   
@Override
protected DataAccessException doTranslate(String task, String sql, SQLException ex) {
    if (ex instanceof SQLTransientException) {
        if (ex instanceof SQLTransientConnectionException) {
            return new TransientDataAccessResourceException(buildMessage(task, sql, ex), ex);
        }
        else if (ex instanceof SQLTransactionRollbackException) {
            return new ConcurrencyFailureException(buildMessage(task, sql, ex), ex);
        }
        else if (ex instanceof SQLTimeoutException) {
            return new QueryTimeoutException(buildMessage(task, sql, ex), ex);
        }
    }
    else if (ex instanceof SQLNonTransientException) {
        if (ex instanceof SQLNonTransientConnectionException) {
            return new DataAccessResourceFailureException(buildMessage(task, sql, ex), ex);
        }
        else if (ex instanceof SQLDataException) {
            return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
        }
        else if (ex instanceof SQLIntegrityConstraintViolationException) {
            return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
        }
        else if (ex instanceof SQLInvalidAuthorizationSpecException) {
            return new PermissionDeniedDataAccessException(buildMessage(task, sql, ex), ex);
        }
        else if (ex instanceof SQLSyntaxErrorException) {
            return new BadSqlGrammarException(task, sql, ex);
        }
        else if (ex instanceof SQLFeatureNotSupportedException) {
            return new InvalidDataAccessApiUsageException(buildMessage(task, sql, ex), ex);
        }
    }
    else if (ex instanceof SQLRecoverableException) {
        return new RecoverableDataAccessException(buildMessage(task, sql, ex), ex);
    }

    // Fallback to Spring's own SQL state translation...
    return null;
}
项目:ProyectoPacientes    文件:ConnectionRegressionTest.java   
/**
 * Tests fix for Bug#16634180 - LOCK WAIT TIMEOUT EXCEEDED CAUSES SQLEXCEPTION, SHOULD CAUSE SQLTRANSIENTEXCEPTION
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug16634180() throws Exception {

    createTable("testBug16634180", "(pk integer primary key, val integer)", "InnoDB");
    this.stmt.executeUpdate("insert into testBug16634180 values(0,0)");

    Connection c1 = null;
    Connection c2 = null;

    try {
        c1 = getConnectionWithProps(new Properties());
        c1.setAutoCommit(false);
        Statement s1 = c1.createStatement();
        s1.executeUpdate("update testBug16634180 set val=val+1 where pk=0");

        c2 = getConnectionWithProps(new Properties());
        c2.setAutoCommit(false);
        Statement s2 = c2.createStatement();
        try {
            s2.executeUpdate("update testBug16634180 set val=val+1 where pk=0");
            fail("ER_LOCK_WAIT_TIMEOUT should be thrown.");
        } catch (SQLTransientException ex) {
            assertEquals(MysqlErrorNumbers.ER_LOCK_WAIT_TIMEOUT, ex.getErrorCode());
            assertEquals(SQLError.SQL_STATE_ROLLBACK_SERIALIZATION_FAILURE, ex.getSQLState());
            assertEquals("Lock wait timeout exceeded; try restarting transaction", ex.getMessage());
        }
    } finally {
        if (c1 != null) {
            c1.close();
        }
        if (c2 != null) {
            c2.close();
        }
    }
}
项目:BibliotecaPS    文件:ConnectionRegressionTest.java   
/**
 * Tests fix for Bug#16634180 - LOCK WAIT TIMEOUT EXCEEDED CAUSES SQLEXCEPTION, SHOULD CAUSE SQLTRANSIENTEXCEPTION
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug16634180() throws Exception {

    createTable("testBug16634180", "(pk integer primary key, val integer)", "InnoDB");
    this.stmt.executeUpdate("insert into testBug16634180 values(0,0)");

    Connection c1 = null;
    Connection c2 = null;

    try {
        c1 = getConnectionWithProps(new Properties());
        c1.setAutoCommit(false);
        Statement s1 = c1.createStatement();
        s1.executeUpdate("update testBug16634180 set val=val+1 where pk=0");

        c2 = getConnectionWithProps(new Properties());
        c2.setAutoCommit(false);
        Statement s2 = c2.createStatement();
        try {
            s2.executeUpdate("update testBug16634180 set val=val+1 where pk=0");
            fail("ER_LOCK_WAIT_TIMEOUT should be thrown.");
        } catch (SQLTransientException ex) {
            assertEquals(MysqlErrorNumbers.ER_LOCK_WAIT_TIMEOUT, ex.getErrorCode());
            assertEquals(SQLError.SQL_STATE_ROLLBACK_SERIALIZATION_FAILURE, ex.getSQLState());
            assertEquals("Lock wait timeout exceeded; try restarting transaction", ex.getMessage());
        }
    } finally {
        if (c1 != null) {
            c1.close();
        }
        if (c2 != null) {
            c2.close();
        }
    }
}
项目:jdk8u-jdk    文件:SQLTransientExceptionTests.java   
/**
 * Create SQLTransientException and setting all objects to null
 */
@Test
public void test() {
    SQLTransientException e = new SQLTransientException(null,
            null, errorCode, null);
    assertTrue(e.getMessage() == null && e.getSQLState() == null
            && e.getCause() == null && e.getErrorCode() == errorCode);
}
项目:jdk8u-jdk    文件:SQLTransientExceptionTests.java   
/**
 * Create SQLTransientException with no-arg constructor
 */
@Test
public void test1() {
    SQLTransientException ex = new SQLTransientException();
    assertTrue(ex.getMessage() == null
            && ex.getSQLState() == null
            && ex.getCause() == null
            && ex.getErrorCode() == 0);
}
项目:jdk8u-jdk    文件:SQLTransientExceptionTests.java   
/**
 * Create SQLTransientException with message
 */
@Test
public void test2() {
    SQLTransientException ex = new SQLTransientException(reason);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState() == null
            && ex.getCause() == null
            && ex.getErrorCode() == 0);
}