Package java.sql

Examples of java.sql.DataTruncation


    /*
     * Method test for getRead
     */
    public void testGetRead() {

        DataTruncation aDataTruncation;
        int[] init1 = { -2147483648, 2147483647, 0, 2092420209, -1695764964,
                1832837995, -80199594 };
        boolean[] init2 = { false, true, false, false, false, true, true };
        boolean[] init3 = { false, true, false, false, true, true, false };
        int[] init4 = { -2147483648, 2147483647, 0, 1762375167, -604897453,
                1362491587, 1007466498 };
        int[] init5 = { -2147483648, 2147483647, 0, 1494407222, -1696982311,
                -940493360, -1777579868 };

        boolean theReturn;
        boolean[] theReturns = init3;
        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.getRead();
                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 getDataSize
     */
    public void testGetDataSize() {

        DataTruncation aDataTruncation;
        int[] init1 = { -2147483648, 2147483647, 0, 1146707040, -2020665632,
                1268632617, -1595624039 };
        boolean[] init2 = { false, true, false, true, false, true, true };
        boolean[] init3 = { false, true, false, true, true, false, false };
        int[] init4 = { -2147483648, 2147483647, 0, -367493363, 328996907,
                -1581326731, 835022052 };
        int[] init5 = { -2147483648, 2147483647, 0, -886134194, 908213800,
                1123419516, -429606389 };

        int theReturn;
        int[] theReturns = init4;
        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.getDataSize();
                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 getTransferSize
     */
    public void testGetTransferSize() {

        DataTruncation aDataTruncation;
        int[] init1 = { -2147483648, 2147483647, 0, 78096124, 1719192600,
                -1661234694, -1205825753 };
        boolean[] init2 = { false, true, false, false, true, false, true };
        boolean[] init3 = { false, true, false, false, false, false, false };
        int[] init4 = { -2147483648, 2147483647, 0, -493779295, -2042560243,
                -217347438, 1357818664 };
        int[] init5 = { -2147483648, 2147483647, 0, -1647009002, -717544563,
                -1368171905, -918209633 };

        int theReturn;
        int[] theReturns = init5;
        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.getTransferSize();
                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

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

    /**
     * @tests serialization/deserialization compatibility with RI.
     */
    public void testSerializationCompatibility() throws Exception {
        DataTruncation object = new DataTruncation(10, true, true, 10, 10);
        SerializationTest.verifyGolden(this, object, DATATRUNCATION_COMPARATOR);
    }
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, code); //$NON-NLS-1$

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

  }

  private void issueDataTruncationWarningIfConfigured(int columnIndex,
      int readSize, int truncatedToSize) {
    DataTruncation dt = new DataTruncation(columnIndex, false, true,
        readSize, truncatedToSize);
  }
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

            // If invoked as part of statement execution, and the client
            // supports receiving DataTruncation warnings, add a warning about
            // the string being truncated.
            if (warnOnTruncation && stmt != null) {
                DataTruncation dt = new DataTruncation(
                        index,
                        isParameter,
                        true,  // this is a warning for a read operation
                        s.length(),                   // dataSize
                        s.length() - truncatedChars); // transferSize
View Full Code Here

     */
    DataTruncation getDataTruncation() {
        // The network server has serialized all the parameters needed by
        // the constructor in the SQLERRMC field.
        String[] tokens = getSqlErrmc().split(SQLERRMC_TOKEN_DELIMITER);
        return new DataTruncation(
                Integer.parseInt(tokens[0]),                // index
                Boolean.valueOf(tokens[1]).booleanValue()// parameter
                Boolean.valueOf(tokens[2]).booleanValue()// read
                Integer.parseInt(tokens[3]),                // dataSize
                Integer.parseInt(tokens[4]));               // transferSize
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.