Java Code Examples for java.sql.BatchUpdateException#setNextException()

The following examples show how to use java.sql.BatchUpdateException#setNextException() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BatchUpdateExceptionTests.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test16() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc,  t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    SQLException sqe = ex;
    int num = 0;
    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();
    }
}
 
Example 2
Source File: BatchUpdateExceptionTests.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test16() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc,  t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    SQLException sqe = ex;
    int num = 0;
    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();
    }
}
 
Example 3
Source File: BatchUpdateExceptionTests.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test16() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc,  t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    SQLException sqe = ex;
    int num = 0;
    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();
    }
}
 
Example 4
Source File: BatchUpdateExceptionTests.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test16() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc,  t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    SQLException sqe = ex;
    int num = 0;
    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();
    }
}
 
Example 5
Source File: BatchUpdateExceptionTests.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test16() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc,  t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    SQLException sqe = ex;
    int num = 0;
    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();
    }
}
 
Example 6
Source File: BatchUpdateExceptionTests.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test16() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc,  t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    SQLException sqe = ex;
    int num = 0;
    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();
    }
}
 
Example 7
Source File: BatchUpdateExceptionTests.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test16() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc,  t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    SQLException sqe = ex;
    int num = 0;
    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();
    }
}
 
Example 8
Source File: SQLErrorCodeSQLExceptionTranslatorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void batchExceptionTranslation() {
	SQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator(ERROR_CODES);

	SQLException badSqlEx = new SQLException("", "", 1);
	BatchUpdateException batchUpdateEx = new BatchUpdateException();
	batchUpdateEx.setNextException(badSqlEx);
	BadSqlGrammarException bsgex = (BadSqlGrammarException) sext.translate("task", "SQL", batchUpdateEx);
	assertEquals("SQL", bsgex.getSql());
	assertEquals(badSqlEx, bsgex.getSQLException());
}
 
Example 9
Source File: SQLErrorCodeSQLExceptionTranslatorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void batchExceptionTranslation() {
	SQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator(ERROR_CODES);

	SQLException badSqlEx = new SQLException("", "", 1);
	BatchUpdateException batchUpdateEx = new BatchUpdateException();
	batchUpdateEx.setNextException(badSqlEx);
	BadSqlGrammarException bsgex = (BadSqlGrammarException) sext.translate("task", "SQL", batchUpdateEx);
	assertEquals("SQL", bsgex.getSql());
	assertEquals(badSqlEx, bsgex.getSQLException());
}
 
Example 10
Source File: BatchUpdateExceptionTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using for-each loop
 */
@Test
public void test15() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 11
Source File: BatchUpdateExceptionTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using for-each loop
 */
@Test
public void test15() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 12
Source File: BatchUpdateExceptionTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using for-each loop
 */
@Test
public void test15() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 13
Source File: SQLErrorCodeSQLExceptionTranslatorTests.java    From effectivejava with Apache License 2.0 5 votes vote down vote up
public void testBatchExceptionTranslation() {
	SQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator(ERROR_CODES);

	SQLException badSqlEx = new SQLException("", "", 1);
	BatchUpdateException batchUpdateEx = new BatchUpdateException();
	batchUpdateEx.setNextException(badSqlEx);
	BadSqlGrammarException bsgex = (BadSqlGrammarException) sext.translate("task", "SQL", batchUpdateEx);
	assertEquals("SQL", bsgex.getSql());
	assertEquals(badSqlEx, bsgex.getSQLException());
}
 
Example 14
Source File: BatchUpdateExceptionTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using for-each loop
 */
@Test
public void test15() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 15
Source File: DatabaseTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateKettleDatabaseBatchExceptionConstructsExceptionList() {
  BatchUpdateException root = new BatchUpdateException();
  SQLException next = new SQLException();
  SQLException next2 = new SQLException();
  root.setNextException( next );
  next.setNextException( next2 );
  List<Exception> exceptionList = Database.createKettleDatabaseBatchException( "", root ).getExceptionsList();
  assertEquals( 2, exceptionList.size() );
  assertEquals( next, exceptionList.get( 0 ) );
  assertEquals( next2, exceptionList.get( 1 ) );
}
 
Example 16
Source File: BatchUpdateExceptionTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using for-each loop
 */
@Test
public void test15() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 17
Source File: SQLErrorCodeSQLExceptionTranslatorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void batchExceptionTranslation() {
	SQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator(ERROR_CODES);

	SQLException badSqlEx = new SQLException("", "", 1);
	BatchUpdateException batchUpdateEx = new BatchUpdateException();
	batchUpdateEx.setNextException(badSqlEx);
	BadSqlGrammarException bsgex = (BadSqlGrammarException) sext.translate("task", "SQL", batchUpdateEx);
	assertEquals("SQL", bsgex.getSql());
	assertEquals(badSqlEx, bsgex.getSQLException());
}
 
Example 18
Source File: BatchUpdateExceptionTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using for-each loop
 */
@Test
public void test15() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 19
Source File: BatchUpdateExceptionTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using for-each loop
 */
@Test
public void test15() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 20
Source File: DatabaseTest.java    From hop with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateHopDatabaseBatchExceptionConstructsExceptionList() {
  BatchUpdateException root = new BatchUpdateException();
  SQLException next = new SQLException();
  SQLException next2 = new SQLException();
  root.setNextException( next );
  next.setNextException( next2 );
  List<Exception> exceptionList = Database.createHopDatabaseBatchException( "", root ).getExceptionsList();
  assertEquals( 2, exceptionList.size() );
  assertEquals( next, exceptionList.get( 0 ) );
  assertEquals( next2, exceptionList.get( 1 ) );
}