Package java.sql

Examples of java.sql.DataTruncation


    void truncate(int sourceWidth, int desiredWidth, boolean warn)
            throws StandardException {
        if (warn) {
            // SQL:2003, part 2, 6.12 <cast specification>,
            // general rule 12 says we should warn about truncation.
            DataTruncation warning = new DataTruncation(
                    -1,    // column index is unknown
                    false, // parameter
                    true,  // read
                    getLength(), desiredWidth);
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

                String source = getString();
                int transferSize = getUTF8Length(source, 0, desiredWidth);
                int dataSize = transferSize +
                        getUTF8Length(source, desiredWidth, source.length());

                DataTruncation warning = new DataTruncation(
                    -1,     // column index is unknown
                    false,  // parameter
                    true,   // read
                    dataSize,
                    transferSize);

                warning.initCause(se);

                StatementContext statementContext = (StatementContext)
                    ContextService.getContext(ContextId.LANG_STATEMENT);
                statementContext.getActivation().
                        getResultSet().addWarning(warning);
View Full Code Here

        assertNotNull("Expected data truncation warning", warning);
        for (int i = 0; i < expectedRow.length; i++) {
            assertEquals("column #" + (i + 1), expectedRow[i], actualRow[i]);

            if (warning instanceof DataTruncation) {
                DataTruncation dt = (DataTruncation) warning;
                assertEquals("index", index, dt.getIndex());
                assertEquals("parameter", parameter, dt.getParameter());
                assertEquals("read", read, dt.getRead());
                assertEquals("dataSize", dataSize, dt.getDataSize());
                assertEquals("transferSize", transferSize, dt.getTransferSize());
            } else {
                fail("Unexpected warning", warning);
            }

            assertNull("Chained warnings not expected on network client",
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

        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

    void truncate(int sourceWidth, int desiredWidth, boolean warn)
            throws StandardException {
        if (warn) {
            // SQL:2003, part 2, 6.12 <cast specification>,
            // general rule 12 says we should warn about truncation.
            DataTruncation warning = new DataTruncation(
                    -1,    // column index is unknown
                    false, // parameter
                    true,  // read
                    getLength(), desiredWidth);
View Full Code Here

                String source = getString();
                int transferSize = getUTF8Length(source, 0, desiredWidth);
                int dataSize = transferSize +
                        getUTF8Length(source, desiredWidth, source.length());

                DataTruncation warning = new DataTruncation(
                    -1,     // column index is unknown
                    false,  // parameter
                    true,   // read
                    dataSize,
                    transferSize);

                warning.initCause(se);

                StatementContext statementContext = (StatementContext)
                    ContextService.getContext(ContextId.LANG_STATEMENT);
                statementContext.getActivation().
                        getResultSet().addWarning(warning);
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

        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

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.