Here are the examples of the java api class java.sql.BatchUpdateException taken from open source projects.
1. BatchUpdateExceptionTests#test16()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * 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(); } }
2. BatchUpdateExceptionTests#test15()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * 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())); } }
3. DatabaseUnitTest#testCreateKettleDatabaseBatchExceptionConstructsExceptionList()
Project: pentaho-kettle
File: DatabaseUnitTest.java
File: DatabaseUnitTest.java
@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)); }
4. BatchUpdateExceptionTests#test14()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * Serialize a BatchUpdateException with an Integer.MAX_VALUE + 1 and * validate you can read it back properly */ @Test public void test14() throws Exception { int[] uc1 = { Integer.MAX_VALUE, Integer.MAX_VALUE + 1 }; long[] luc1 = { Integer.MAX_VALUE, Integer.MAX_VALUE + 1 }; BatchUpdateException be = new BatchUpdateException(reason, state, errorCode, luc1, 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(), luc1) && Arrays.equals(bue.getUpdateCounts(), uc1)); }
5. BatchUpdateExceptionTests#test12()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * 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)); }
6. BatchUpdateTest#testUnderlyingExceptionIsVisible()
Project: derby
File: BatchUpdateTest.java
File: BatchUpdateTest.java
/** * Test that the underlying exception is included in the output when we * call printStackTrace() on a BatchUpdateException. Earlier, with the * client driver, the underlying cause of a BatchUpdateException could not * be seen without calling getNextException(). */ public void testUnderlyingExceptionIsVisible() throws SQLException { setAutoCommit(false); Statement s = createStatement(); s.addBatch("create table t(x int unique not null)"); for (int i = 0; i < 3; i++) { s.addBatch("insert into t values 1"); } BatchUpdateException bue = null; try { s.executeBatch(); } catch (BatchUpdateException e) { bue = e; } assertNotNull("Did not get duplicate key exception", bue); StringWriter w = new StringWriter(); bue.printStackTrace(new PrintWriter(w, true)); String stackTrace = w.toString(); if (stackTrace.indexOf("duplicate key") == -1) { fail("Could not see 'duplicate key' in printStackTrace()", bue); } }
7. BatchUpdateExceptionTests#test13()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * De-Serialize a BatchUpdateException from JDBC 4.0 and make sure you can * read it back properly */ @Test public void test13() throws Exception { String reason1 = "This was the error msg"; String state1 = "user defined sqlState"; String cause1 = "java.lang.Throwable: throw 1"; int errorCode1 = 99999; Throwable t = new Throwable("throw 1"); int[] uc1 = { 1, 2, 21 }; long[] luc1 = { 1, 2, 21 }; ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(SerializedBatchUpdateException.DATA)); BatchUpdateException bue = (BatchUpdateException) ois.readObject(); assertTrue(reason1.equals(bue.getMessage()) && bue.getSQLState().equals(state1) && bue.getErrorCode() == errorCode1 && cause1.equals(bue.getCause().toString()) && Arrays.equals(bue.getLargeUpdateCounts(), luc1) && Arrays.equals(bue.getUpdateCounts(), uc1)); }
8. BatchUpdateExceptionTests#test9()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * 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)); }
9. BatchUpdateExceptionTests#test8()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * Create BatchUpdateException with message, SQLState, errorCode code * Throwable, and update counts */ @Test public void test8() { BatchUpdateException ex = new BatchUpdateException(reason, state, errorCode, uc, 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)); }
10. BatchUpdateExceptionTests#test3()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * Create BatchUpdateException with message and update counts */ @Test public void test3() { BatchUpdateException ex = new BatchUpdateException(reason, uc); assertTrue(ex.getMessage().equals(reason) && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0 && Arrays.equals(ex.getUpdateCounts(), uc) && Arrays.equals(ex.getLargeUpdateCounts(), luc)); }
11. ClientJDBCObjectFactoryImpl#newBatchUpdateException()
Project: derby
File: ClientJDBCObjectFactoryImpl.java
File: ClientJDBCObjectFactoryImpl.java
/** This method is overridden on JVM 8 */ protected BatchUpdateException newBatchUpdateException(String message, String sqlState, int errorCode, long[] updateCounts, SqlException cause) { BatchUpdateException bue = new BatchUpdateException(message, sqlState, errorCode, Utils.squashLongs(updateCounts)); if (cause != null) { bue.initCause(cause); } return bue; }
12. ClientJDBCObjectFactoryImpl#newBatchUpdateException()
Project: derby
File: ClientJDBCObjectFactoryImpl.java
File: ClientJDBCObjectFactoryImpl.java
/** * Creates a BatchUpdateException depending on the JVM level. */ public BatchUpdateException newBatchUpdateException(LogWriter logWriter, ClientMessageId msgid, Object[] args, long[] updateCounts, SqlException cause) { BatchUpdateException bue = newBatchUpdateException(msgutil_.getCompleteMessage(msgid.msgid, args), ExceptionUtil.getSQLStateFromIdentifier(msgid.msgid), ExceptionUtil.getSeverityFromIdentifier(msgid.msgid), updateCounts, cause); if (logWriter != null) { logWriter.traceDiagnosable(bue); } if (cause != null) { bue.setNextException(cause.getSQLException()); } return bue; }
13. SQLErrorCodeSQLExceptionTranslatorTests#testBatchExceptionTranslation()
Project: effectivejava
File: SQLErrorCodeSQLExceptionTranslatorTests.java
File: SQLErrorCodeSQLExceptionTranslatorTests.java
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()); }
14. BatchUpdateExceptionTests#test11()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * Validate that if null is specified for the update count, it is returned * as null */ @Test public void test11() { BatchUpdateException ex = new BatchUpdateException((int[]) null); assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getErrorCode() == 0 && ex.getUpdateCounts() == null && ex.getLargeUpdateCounts() == null); }
15. BatchUpdateExceptionTests#test10()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * Validate that a copy of the update counts array is made */ @Test public void test10() { int[] uc1 = { 1, 2 }; BatchUpdateException ex = new BatchUpdateException(uc1); assertTrue(Arrays.equals(ex.getUpdateCounts(), uc1)); uc1[0] = 6689; assertFalse(Arrays.equals(ex.getUpdateCounts(), uc1)); }
16. BatchUpdateExceptionTests#test7()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * Create BatchUpdateException with message, SQLState, Throwable, and update * counts */ @Test public void test7() { BatchUpdateException ex = new BatchUpdateException(reason, state, uc, t); assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == 0 && Arrays.equals(ex.getUpdateCounts(), uc) && Arrays.equals(ex.getLargeUpdateCounts(), luc)); }
17. BatchUpdateExceptionTests#test6()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * Create BatchUpdateException with message, Throwable, and update counts */ @Test public void test6() { BatchUpdateException ex = new BatchUpdateException(reason, uc, t); assertTrue(ex.getMessage().equals(reason) && ex.getSQLState() == null && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == 0 && Arrays.equals(ex.getUpdateCounts(), uc) && Arrays.equals(ex.getLargeUpdateCounts(), luc)); }
18. BatchUpdateExceptionTests#test5()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * 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)); }
19. BatchUpdateExceptionTests#test4()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * Create BatchUpdateException with update counts */ @Test public void test4() { BatchUpdateException ex = new BatchUpdateException(uc); assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0 && Arrays.equals(ex.getUpdateCounts(), uc) && Arrays.equals(ex.getLargeUpdateCounts(), luc)); }
20. BatchUpdateExceptionTests#test2()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * Create BatchUpdateException with null Throwable */ @Test public void test2() { BatchUpdateException ex = new BatchUpdateException((Throwable) null); assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0 && ex.getUpdateCounts() == null && ex.getLargeUpdateCounts() == null); }
21. BatchUpdateExceptionTests#test1()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * Create BatchUpdateException with no-arg constructor */ @Test public void test1() { BatchUpdateException ex = new BatchUpdateException(); assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0 && ex.getUpdateCounts() == null && ex.getLargeUpdateCounts() == null); }
22. BatchUpdateExceptionTests#test()
Project: openjdk
File: BatchUpdateExceptionTests.java
File: BatchUpdateExceptionTests.java
/** * 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); }