Package java.sql

Examples of java.sql.BatchUpdateException


     * @since 1.6
     */
    public void testBatchUpdateException$ILThrowable() {
        Throwable cause = new Exception("MYTHROWABLE");
        int[] updateCounts = new int[] { 1, 2, 3 };
        BatchUpdateException batchUpdateException = new BatchUpdateException(
                updateCounts, cause);
        assertNotNull(batchUpdateException);
        assertEquals("java.lang.Exception: MYTHROWABLE", batchUpdateException
                .getMessage());
        int[] result = batchUpdateException.getUpdateCounts();
        for (int i = 0; i < updateCounts.length; i++) {
            assertEquals(updateCounts[i], result[i]);
        }
        assertEquals(cause, batchUpdateException.getCause());
    }
View Full Code Here


     * @since 1.6
     */
    public void testBatchUpdateExceptionLString$ILThrowable() {
        Throwable cause = new Exception("MYTHROWABLE");
        int[] updateCounts = new int[] { 1, 2, 3 };
        BatchUpdateException batchUpdateException = new BatchUpdateException(
                "MYTESTSTRING1", "MYTESTSTRING2", updateCounts, cause);
        assertNotNull(batchUpdateException);
        assertEquals("MYTESTSTRING2", batchUpdateException.getSQLState());
        assertEquals("MYTESTSTRING1", batchUpdateException.getMessage());
        assertEquals(0, batchUpdateException.getErrorCode());
        int[] result = batchUpdateException.getUpdateCounts();
        for (int i = 0; i < updateCounts.length; i++) {
            assertEquals(updateCounts[i], result[i]);
        }
        assertEquals(cause, batchUpdateException.getCause());
    }
View Full Code Here

     *
     * @since 1.6
     */
    public void testBatchUpdateExceptionLStringLStringILThrowable() {
        int[] updateCounts = new int[] { 1, 2, 3 };
        BatchUpdateException batchUpdateException = new BatchUpdateException(
                null, null, updateCounts, null);
        assertNotNull(batchUpdateException);
        assertNull(batchUpdateException.getSQLState());
        assertNull(batchUpdateException.getMessage());
        assertEquals(0, batchUpdateException.getErrorCode());
        assertNull(batchUpdateException.getCause());
    }
View Full Code Here

     * @tests {@link java.sql.BatchUpdateException#BatchUpdateException(String, String, int, int[], Throwable)}
     *
     * @since 1.6
     */
    public void testBatchUpdateExceptionLStringLStringI$ILThrowable() {
        BatchUpdateException batchUpdateException = new BatchUpdateException(
                "MYTESTSTRING1", "MYTESTSTRING2", 1, null);
        assertNotNull(batchUpdateException);
        assertEquals("MYTESTSTRING2", batchUpdateException.getSQLState());
        assertEquals("MYTESTSTRING1", batchUpdateException.getMessage());
        assertEquals(batchUpdateException.getErrorCode(), 1);
        assertNull(batchUpdateException.getCause());
    }
View Full Code Here

    /*
     * Method test for getUpdateCounts
     */
    public void testGetUpdateCounts() {

        BatchUpdateException aBatchUpdateException;
        int[][] init1 = { { 1, 2, 3 }, {}, null };

        int[] theReturn;
        int[][] theReturns = init1;

        int[] theFinalStates1 = { 0, 0, 0 }; // Error Code state
        int[][] theFinalStates2 = init1; // Update Counts array state
        String[] theFinalStates3 = { null, null, null }; // SQL State state
        // value
        String[] theFinalStates4 = { null, null, null }; // Message state

        Exception[] theExceptions = { null, null, null };

        int loopCount = init1.length;
        for (int i = 0; i < loopCount; i++) {
            try {
                aBatchUpdateException = new BatchUpdateException(init1[i]);
                theReturn = aBatchUpdateException.getUpdateCounts();
                if (theExceptions[i] != null) {
                    fail(i + "Exception missed");
                }
                assertEquals(i + "Return value mismatch", theReturn,
                        theReturns[i]);
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getErrorCode(),
                        theFinalStates1[i]);
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getUpdateCounts(),
                        theFinalStates2[i]);
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getSQLState(), theFinalStates3[i]);
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getMessage(), theFinalStates4[i]);

            } catch (Exception e) {
                if (theExceptions[i] == null) {
                    fail(i + "Unexpected exception");
                }
View Full Code Here

    /**
     * @tests serialization/deserialization compatibility.
     */
    public void testSerializationSelf() throws Exception {
        BatchUpdateException object = new BatchUpdateException();
        SerializationTest.verifySelf(object, BATCHUPDATEEXCEPTION_COMPARATOR);
    }
View Full Code Here

     * @tests serialization/deserialization compatibility with RI.
     */
    public void testSerializationCompatibility() throws Exception {
        int vendorCode = 10;
        int[] updateCounts = { 1, 2, 3, 4 };
        BatchUpdateException object = new BatchUpdateException("reason",
                "SQLState", vendorCode, updateCounts);
        SerializationTest.verifyGolden(this, object,
                BATCHUPDATEEXCEPTION_COMPARATOR);
    }
View Full Code Here

        String[] theFinalStates3 = { null }; // SQL State state value
        String[] theFinalStates4 = { null }; // Message state

        Exception[] theExceptions = { null };

        BatchUpdateException aBatchUpdateException;
        int loopCount = 1;
        for (int i = 0; i < loopCount; i++) {
            try {
                aBatchUpdateException = new BatchUpdateException();
                if (theExceptions[i] != null) {
                    fail();
                }
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getErrorCode(),
                        theFinalStates1[i]);
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getUpdateCounts(),
                        theFinalStates2[i]);
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getSQLState(), theFinalStates3[i]);
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getMessage(), theFinalStates4[i]);

            } catch (Exception e) {
                if (theExceptions[i] == null) {
                    fail(i + "Unexpected exception");
                }
View Full Code Here

        String[] theFinalStates3 = { null, null }; // SQL State state value
        String[] theFinalStates4 = { null, null }; // Message state

        Exception[] theExceptions = { null, null };

        BatchUpdateException aBatchUpdateException;
        int loopCount = init1.length;
        for (int i = 0; i < loopCount; i++) {
            try {
                aBatchUpdateException = new BatchUpdateException(init1[i]);
                if (theExceptions[i] != null) {
                    fail();
                }
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getErrorCode(),
                        theFinalStates1[i]);
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getUpdateCounts(),
                        theFinalStates2[i]);
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getSQLState(), theFinalStates3[i]);
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getMessage(), theFinalStates4[i]);

            } catch (Exception e) {
                if (theExceptions[i] == null) {
                    fail(i + "Unexpected exception");
                }
View Full Code Here

        String[] theFinalStates4 = init1; // Message state

        Exception[] theExceptions = { null, null, null, null, null, null, null,
                null, null };

        BatchUpdateException aBatchUpdateException;
        int loopCount = init1.length;
        for (int i = 0; i < loopCount; i++) {
            try {
                aBatchUpdateException = new BatchUpdateException(init1[i],
                        init2[i]);
                if (theExceptions[i] != null) {
                    fail();
                }
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getErrorCode(),
                        theFinalStates1[i]);
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getUpdateCounts(),
                        theFinalStates2[i]);
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getSQLState(), theFinalStates3[i]);
                assertEquals(i + " Final state mismatch: ",
                        aBatchUpdateException.getMessage(), theFinalStates4[i]);

            } catch (Exception e) {
                if (theExceptions[i] == null) {
                    fail(i + "Unexpected exception");
                }
View Full Code Here

TOP

Related Classes of java.sql.BatchUpdateException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.