Search in sources :

Example 11 with BatchUpdateException

use of java.sql.BatchUpdateException in project jdk8u_jdk by JetBrains.

the class BatchUpdateExceptionTests method test12.

/**
     * Serialize a BatchUpdateException and make sure you can read it back
     * properly
     */
@Test
public void test12() throws Exception {
    BatchUpdateException be = new BatchUpdateException(reason, state, errorCode, uc, t);
    BatchUpdateException bue = createSerializedException(be);
    assertTrue(reason.equals(bue.getMessage()) && bue.getSQLState().equals(state) && cause.equals(bue.getCause().toString()) && bue.getErrorCode() == errorCode && Arrays.equals(bue.getLargeUpdateCounts(), luc) && Arrays.equals(bue.getUpdateCounts(), uc));
}
Also used : BatchUpdateException(java.sql.BatchUpdateException) SerializedBatchUpdateException(util.SerializedBatchUpdateException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 12 with BatchUpdateException

use of java.sql.BatchUpdateException in project jdk8u_jdk by JetBrains.

the class BatchUpdateExceptionTests method test5.

/**
     * Create BatchUpdateException with Throwable and update counts
     */
@Test
public void test5() {
    BatchUpdateException ex = new BatchUpdateException(uc, t);
    assertTrue(ex.getMessage().equals(cause) && ex.getSQLState() == null && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == 0 && Arrays.equals(ex.getUpdateCounts(), uc) && Arrays.equals(ex.getLargeUpdateCounts(), luc));
}
Also used : BatchUpdateException(java.sql.BatchUpdateException) SerializedBatchUpdateException(util.SerializedBatchUpdateException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 13 with BatchUpdateException

use of java.sql.BatchUpdateException in project jdk8u_jdk by JetBrains.

the class BatchUpdateExceptionTests method test9.

/**
     * Create BatchUpdateException with message, SQLState, errorCode code
     * Throwable, and long [] update counts
     */
@Test
public void test9() {
    BatchUpdateException ex = new BatchUpdateException(reason, state, errorCode, luc, t);
    assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == errorCode && Arrays.equals(ex.getUpdateCounts(), uc) && Arrays.equals(ex.getLargeUpdateCounts(), luc));
}
Also used : BatchUpdateException(java.sql.BatchUpdateException) SerializedBatchUpdateException(util.SerializedBatchUpdateException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 14 with BatchUpdateException

use of java.sql.BatchUpdateException in project jdk8u_jdk by JetBrains.

the class BatchUpdateExceptionTests method test.

/**
     * Create BatchUpdateException and setting all objects to null
     */
@Test
public void test() {
    BatchUpdateException be = new BatchUpdateException(null, null, errorCode, (int[]) null, null);
    assertTrue(be.getMessage() == null && be.getSQLState() == null && be.getUpdateCounts() == null && be.getCause() == null && be.getLargeUpdateCounts() == null && be.getErrorCode() == errorCode);
}
Also used : BatchUpdateException(java.sql.BatchUpdateException) SerializedBatchUpdateException(util.SerializedBatchUpdateException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 15 with BatchUpdateException

use of java.sql.BatchUpdateException in project jdk8u_jdk by JetBrains.

the class BatchUpdateExceptionTests method test15.

/**
     * 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()));
    }
}
Also used : BatchUpdateException(java.sql.BatchUpdateException) SerializedBatchUpdateException(util.SerializedBatchUpdateException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Aggregations

BatchUpdateException (java.sql.BatchUpdateException)103 SQLException (java.sql.SQLException)39 PreparedStatement (java.sql.PreparedStatement)33 Statement (java.sql.Statement)22 ArrayList (java.util.ArrayList)19 Test (org.junit.Test)19 Connection (java.sql.Connection)17 Test (org.testng.annotations.Test)17 BaseTest (util.BaseTest)17 SerializedBatchUpdateException (util.SerializedBatchUpdateException)17 ResultSet (java.sql.ResultSet)13 List (java.util.List)12 CallableStatement (java.sql.CallableStatement)8 HashSet (java.util.HashSet)8 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)7 HashMap (java.util.HashMap)6 Map (java.util.Map)5 CustomChangeException (liquibase.exception.CustomChangeException)5 DatabaseException (liquibase.exception.DatabaseException)5 SetupException (liquibase.exception.SetupException)5