Package java.sql

Examples of java.sql.DataTruncation


    /**
     * Test method for {@link net.sourceforge.squirrel_sql.fw.util.DefaultExceptionFormatter#format(java.lang.Throwable)}.
     */   
    @Test
    public void testDefaultFormatForDataTruncationWrite() {
        DataTruncation dt = new DataTruncation(1, true, false, 20, 3);
        Assert.assertTrue(formatterUnderTest.formatsException(dt));
       
        StringBuilder expectedMessage =
            new StringBuilder("Data Truncation error occured on");
        expectedMessage.append(" a write ");
View Full Code Here


        Assert.assertTrue(formatterUnderTest.formatsException(new SQLException()));
        Assert.assertTrue(formatterUnderTest.formatsException(new SQLExecutionException(new SQLException(), "")));
        Assert.assertTrue(formatterUnderTest.formatsException(new SQLExecutionException(new SQLException(), "some error")));
        Assert.assertTrue(formatterUnderTest.formatsException(new SQLExecutionException(new SQLException(), null)));
        Assert.assertTrue(formatterUnderTest.formatsException(new IOException()));
        Assert.assertTrue(formatterUnderTest.formatsException(new DataTruncation(0, true, true, 0, 0)));
        Assert.assertTrue(formatterUnderTest.formatsException(new SQLWarning()));
    }
View Full Code Here

     
      return (map1 != null) && (map2 != null) ? map1.equals(map2) : (map1 != map2);
    }
    else if ((exception1 instanceof DataTruncation) && (exception2 instanceof DataTruncation))
    {
      DataTruncation e1 = (DataTruncation) exception1;
      DataTruncation e2 = (DataTruncation) exception2;
     
      return (e1.getDataSize() == e2.getDataSize()) && (e1.getIndex() == e2.getIndex()) && (e1.getParameter() == e2.getParameter()) && (e1.getRead() == e2.getRead()) && (e1.getTransferSize() == e2.getTransferSize());
    }
   
    SQLException nextException1 = exception1.getNextException();
    SQLException nextException2 = exception2.getNextException();
   
View Full Code Here

    assertFalse(this.dialect.indicatesFailure(new SQLRecoverableException()));
    assertFalse(this.dialect.indicatesFailure(new SQLTransientException()));
    assertFalse(this.dialect.indicatesFailure(new SQLTimeoutException()));
    assertFalse(this.dialect.indicatesFailure(new SQLTransactionRollbackException()));
    assertFalse(this.dialect.indicatesFailure(new SQLWarning()));
    assertFalse(this.dialect.indicatesFailure(new DataTruncation(1, false, false, 1, 1)));
    assertFalse(this.dialect.indicatesFailure(new SQLDataException()));
    assertFalse(this.dialect.indicatesFailure(new SyncFactoryException()));
    assertFalse(this.dialect.indicatesFailure(new SyncProviderException()));
  }
View Full Code Here

    assertFalse(this.dialect.indicatesFailure(new SQLRecoverableException()));
    assertFalse(this.dialect.indicatesFailure(new SQLTransientException()));
    assertFalse(this.dialect.indicatesFailure(new SQLTimeoutException()));
    assertFalse(this.dialect.indicatesFailure(new SQLTransactionRollbackException()));
    assertFalse(this.dialect.indicatesFailure(new SQLWarning()));
    assertFalse(this.dialect.indicatesFailure(new DataTruncation(1, false, false, 1, 1)));
    assertFalse(this.dialect.indicatesFailure(new SQLDataException()));
    assertFalse(this.dialect.indicatesFailure(new SyncFactoryException()));
    assertFalse(this.dialect.indicatesFailure(new SyncProviderException()));
  }
View Full Code Here

        assertNotNull("No warning", w);
        if (!(w instanceof DataTruncation)) {
            fail("Not a DataTruncation warning", w);
        }

        DataTruncation dt = (DataTruncation) w;
        assertEquals("Column index", index, dt.getIndex());
        assertEquals("Read", read, dt.getRead());
        assertEquals("Parameter", parameter, dt.getParameter());
        assertEquals("Data size", dataSize, dt.getDataSize());
        assertEquals("Transfer size", transferSize, dt.getTransferSize());
    }
View Full Code Here

            while (warnRs.next()) {
                int code = warnRs.getInt("Code"); //$NON-NLS-1$

                if (forTruncationOnly) {
                    if (code == 1265 || code == 1264) {
                        DataTruncation newTruncation = new MysqlDataTruncation(
                                warnRs.getString("Message"), 0, false, false, 0, 0); //$NON-NLS-1$

                        if (currentWarning == null) {
                            currentWarning = newTruncation;
                        } else {
View Full Code Here

        boolean[] theFinalStates7 = init2;
        boolean[] theFinalStates8 = init3;

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

        DataTruncation aDataTruncation;
        int loopCount = init1.length;
        for (int i = 0; i < loopCount; i++) {
            try {
                aDataTruncation = new DataTruncation(init1[i], init2[i],
                        init3[i], init4[i], init5[i]);
                if (theExceptions[i] != null) {
                    fail();
                }
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getSQLState(), theFinalStates1[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getMessage(), theFinalStates2[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getErrorCode(), theFinalStates3[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getIndex(), theFinalStates4[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getDataSize(), theFinalStates5[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getTransferSize(), theFinalStates6[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getParameter(), theFinalStates7[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getRead(), theFinalStates8[i]);

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

    /*
     * Method test for getIndex
     */
    public void testGetIndex() {

        DataTruncation aDataTruncation;
        int[] init1 = { -2147483648, 2147483647, 0, -2045829673, 1977156911,
                478985827, 1687271915 };
        boolean[] init2 = { false, true, false, false, true, true, true };
        boolean[] init3 = { false, true, false, false, true, true, true };
        int[] init4 = { -2147483648, 2147483647, 0, -631377748, 21025030,
                1215194589, 1064137121 };
        int[] init5 = { -2147483648, 2147483647, 0, -897998505, 997578180,
                735015866, 264619424 };

        int theReturn;
        int[] theReturns = init1;
        String[] theFinalStates1 = { "01004", "01004", "01004", "01004",
                "01004", "01004", "01004" };
        String state2 = "Data truncation";
        String[] theFinalStates2 = { state2, state2, state2, state2, state2,
                state2, state2 };
        int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
        int[] theFinalStates4 = init1;
        int[] theFinalStates5 = init4;
        int[] theFinalStates6 = init5;
        boolean[] theFinalStates7 = init2;
        boolean[] theFinalStates8 = init3;

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

        int loopCount = 1;
        for (int i = 0; i < loopCount; i++) {
            try {
                aDataTruncation = new DataTruncation(init1[i], init2[i],
                        init3[i], init4[i], init5[i]);
                theReturn = aDataTruncation.getIndex();
                if (theExceptions[i] != null) {
                    fail(i + "Exception missed");
                }
                assertEquals(i + "Return value mismatch", theReturn,
                        theReturns[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getSQLState(), theFinalStates1[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getMessage(), theFinalStates2[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getErrorCode(), theFinalStates3[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getIndex(), theFinalStates4[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getDataSize(), theFinalStates5[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getTransferSize(), theFinalStates6[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getParameter(), theFinalStates7[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getRead(), theFinalStates8[i]);

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

    /*
     * Method test for getParameter
     */
    public void testGetParameter() {

        DataTruncation aDataTruncation;
        int[] init1 = { -2147483648, 2147483647, 0, -492314242, 1637665948,
                -305785075, 258819883 };
        boolean[] init2 = { false, true, false, true, true, false, true };
        boolean[] init3 = { false, true, false, false, false, true, true };
        int[] init4 = { -2147483648, 2147483647, 0, 1134512579, 533874007,
                1709608139, 990656593 };
        int[] init5 = { -2147483648, 2147483647, 0, -1566784226, -744009101,
                -444614454, 356465980 };

        boolean theReturn;
        boolean[] theReturns = init2;
        String[] theFinalStates1 = { "01004", "01004", "01004", "01004",
                "01004", "01004", "01004" };
        String state2 = "Data truncation";
        String[] theFinalStates2 = { state2, state2, state2, state2, state2,
                state2, state2 };
        int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
        int[] theFinalStates4 = init1;
        int[] theFinalStates5 = init4;
        int[] theFinalStates6 = init5;
        boolean[] theFinalStates7 = init2;
        boolean[] theFinalStates8 = init3;

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

        int loopCount = 1;
        for (int i = 0; i < loopCount; i++) {
            try {
                aDataTruncation = new DataTruncation(init1[i], init2[i],
                        init3[i], init4[i], init5[i]);
                theReturn = aDataTruncation.getParameter();
                if (theExceptions[i] != null) {
                    fail(i + "Exception missed");
                }
                assertEquals(i + "Return value mismatch", theReturn,
                        theReturns[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getSQLState(), theFinalStates1[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getMessage(), theFinalStates2[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getErrorCode(), theFinalStates3[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getIndex(), theFinalStates4[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getDataSize(), theFinalStates5[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getTransferSize(), theFinalStates6[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getParameter(), theFinalStates7[i]);
                assertEquals(i + "  Final state mismatch", aDataTruncation
                        .getRead(), theFinalStates8[i]);

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

TOP

Related Classes of java.sql.DataTruncation

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.