微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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",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",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",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",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",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",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",Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_1() {
    sqlTransientException sqlTransientException = new sqlTransientException(
            "MYTESTSTRING1",null);
    assertNotNull(sqlTransientException);
    assertEquals(
            "The sqlState of sqlTransientException set and get should be equivalent",0);
    assertNull("The cause of sqlTransientException should be null",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",Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_4() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            null,sqlTransientException.getsqlState());
    assertNull("The reason of sqlTransientException should be null",Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_6() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            null,int,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            "MYTESTSTRING1",1,sqlTransientException.getMessage());
    assertEquals("The error code of sqlTransientException should be 1",1);
    assertEquals(
            "The cause of sqlTransientException set and get should be equivalent",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_1() {
    sqlTransientException sqlTransientException = new sqlTransientException(
            "MYTESTSTRING1",1);
    assertNull("The cause of sqlTransientException should be null",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_2() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            "MYTESTSTRING1",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_3() {
    sqlTransientException sqlTransientException = new sqlTransientException(
            "MYTESTSTRING1",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_4() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            "MYTESTSTRING1",-1,sqlTransientException.getMessage());
    assertEquals("The error code of sqlTransientException should be -1",-1);
    assertEquals(
            "The cause of sqlTransientException set and get should be equivalent",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_5() {
    sqlTransientException sqlTransientException = new sqlTransientException(
            "MYTESTSTRING1",-1);
    assertNull("The cause of sqlTransientException should be null",sqlTransientException.getCause());

}
项目:cn1    文件sqlTransientExceptionTest.java   
/**
 * @test java.sql.sqlTransientException(String,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_6() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            "MYTESTSTRING",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_7() {
    sqlTransientException sqlTransientException = new sqlTransientException(
            "MYTESTSTRING",null);
    assertNotNull(sqlTransientException);
    assertNotNull(sqlTransientException);
    assertNull("The sqlState of sqlTransientException should be null",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_8() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            "MYTESTSTRING",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_10() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            "MYTESTSTRING",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_12() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            null,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_14() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            null,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_15() {
    sqlTransientException sqlTransientException = new sqlTransientException(
            null,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_16() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            null,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_18() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            null,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_20() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            null,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_22() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlTransientException sqlTransientException = new sqlTransientException(
            null,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,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,ex);
        }
        else if (ex instanceof sqlTimeoutException) {
            return new QueryTimeoutException(buildMessage(task,ex);
        }
    }
    else if (ex instanceof sqlNonTransientException) {
        if (ex instanceof sqlNonTransientConnectionException) {
            return new DataAccessResourceFailureException(buildMessage(task,ex);
        }
        else if (ex instanceof sqlDataException) {
            return new DataIntegrityViolationException(buildMessage(task,ex);
        }
        else if (ex instanceof sqlIntegrityConstraintViolationException) {
            return new DataIntegrityViolationException(buildMessage(task,ex);
        }
        else if (ex instanceof sqlInvalidAuthorizationSpecException) {
            return new PermissionDeniedDataAccessException(buildMessage(task,ex);
        }
        else if (ex instanceof sqlSyntaxErrorException) {
            return new BadsqlGrammarException(task,ex);
        }
        else if (ex instanceof sqlFeatureNotSupportedException) {
            return new InvalidDataAccessApiUsageException(buildMessage(task,ex);
        }
    }
    else if (ex instanceof sqlRecoverableException) {
        return new RecoverableDataAccessException(buildMessage(task,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,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,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,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);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。