Package org.apache.derbyTesting.functionTests.util.streams

Examples of org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetReader


        super.initialByteLength = CLOBLENGTH *3 + headerLength;
        super.bytesPerChar = BYTES_PER_CHAR;
        EmbedStatement embStmt = (EmbedStatement)createStatement();
        iClob = new TemporaryClob(embStmt);
        transferData(
            new LoopingAlphabetReader(CLOBLENGTH, CharAlphabet.cjkSubset()),
            iClob.getWriter(1L),
            CLOBLENGTH);
        assertEquals(CLOBLENGTH, iClob.getCharLength());
    }
View Full Code Here


     *
     * @param length the length of the stream in characters
     * @return A stream serving bytes.
     */
    private InputStream getStream(int length) {
        Reader src = new LoopingAlphabetReader(length,
                                        CharAlphabet.modernLatinLowercase());
        InputStream is = new ReaderToUTF8Stream(
                src, length, 0, "CLOB", new ClobStreamHeaderGenerator(false));
        assertTrue("The stream doesn't support mark/reset", is.markSupported());
        return is;
View Full Code Here

                    CharAlphabet ca = getCharAlphabet(1 + rnd.nextInt(3));
                    int length = (int)(rnd.nextDouble() * 64.0 * 1024.0);
                    if (rnd.nextInt(1000) < 500) {
                        // Specify the length.
                        ps.setCharacterStream( 1,
                                new LoopingAlphabetReader(length, ca), length);
                    } else {
                        // Don't specify the length.
                        ps.setCharacterStream(1,
                                new LoopingAlphabetReader(length, ca));
                    }
                    ps.setInt(2, length);
                    length = (int)(rnd.nextDouble() * 64.0 * 1024.0);
                    if (rnd.nextInt(1000) < 500) {
                        // Specify the length.
View Full Code Here

        // We need a few Clobs.
        int length = 71*1024+7;
        PreparedStatement ps =
                prepareStatement("insert into testBlobX1(a,c) values (?,?)");
        ps.setInt(1, 3);
        ps.setCharacterStream(2, new LoopingAlphabetReader(length), length);
        ps.executeUpdate();
        ps.setInt(1, 4);
        ps.setString(2, "short clob");
        ps.executeUpdate();
        ps.close();
View Full Code Here

        Statement s = createStatement();
       
        PreparedStatement ps = prepareStatement("INSERT INTO MB_CLOBTABLE VALUES(?,?)");
        // We allocate 16MB for the test so use something bigger than that.
        ps.setInt(1,1);
        LoopingAlphabetReader reader = new LoopingAlphabetReader(SHORT_CLOB_LENGTH, CharAlphabet.cjkSubset());

        ps.setCharacterStream(2, reader, SHORT_CLOB_LENGTH);
        ps.executeUpdate();

        ResultSet rs = s.executeQuery("SELECT K, LENGTH(C), C FROM MB_CLOBTABLE" +
View Full Code Here

        Statement s = createStatement();

        PreparedStatement ps = prepareStatement("INSERT INTO MB_CLOBTABLE VALUES(?,?)");
        // We allocate 16MB for the test so use something bigger than that.
        ps.setInt(1,1);
        LoopingAlphabetReader reader = new LoopingAlphabetReader(LONG_CLOB_LENGTH, CharAlphabet.cjkSubset());

        ps.setCharacterStream(2, reader, LONG_CLOB_LENGTH);
        ps.executeUpdate();

        ResultSet rs = s.executeQuery("SELECT K, LENGTH(C), C FROM MB_CLOBTABLE" +
View Full Code Here

        s.executeUpdate("CREATE TABLE CLOBTABLE (K INT CONSTRAINT PK PRIMARY KEY, C CLOB(" + LONG_CLOB_LENGTH + "))");

        PreparedStatement ps = prepareStatement("INSERT INTO CLOBTABLE VALUES(?,?)");
        // We allocate 16MB for the test so use something bigger than that.
        ps.setInt(1,1);
        LoopingAlphabetReader reader = new LoopingAlphabetReader(LONG_CLOB_LENGTH);
        if (lengthless) {
            Method m = null;
            try {
                Class<?> c = ps.getClass();
                m = c.getMethod("setCharacterStream",new Class[] {Integer.TYPE,
View Full Code Here

        PreparedStatement ps = prepareStatement(
            "INSERT INTO T_MAIN(V) VALUES (?)");

        int blobLen = clobsize;
        LoopingAlphabetReader stream = new LoopingAlphabetReader(blobLen);
        ps.setCharacterStream(1, stream, blobLen);

        ps.executeUpdate();
        ps.close();

        s.executeUpdate("CREATE TABLE T_COPY ( V1 CLOB(" + clobsize +
                        "), V2 CLOB(" + clobsize + "))");

        // This failed in the repro for DERBY-3645 solved as part of
        // DERBY-4477:
        s.executeUpdate("INSERT INTO T_COPY SELECT  V, V FROM T_MAIN");

        // Check that the two results are identical:
        ResultSet rs = s.executeQuery("SELECT * FROM T_COPY");
        rs.next();
        Reader is = rs.getCharacterStream(1);

        stream = new LoopingAlphabetReader(blobLen);
        assertEquals(stream, is);

        is = rs.getCharacterStream(2);

        stream = new LoopingAlphabetReader(blobLen);
        assertEquals(stream, is);
        rs.close();

        // This failed in the repro for DERBY-3646 solved as part of
        // DERBY-4477 (repro slightly rewoked here):
        rs = s.executeQuery("SELECT 'I', V, ID, V from T_MAIN");
        rs.next();

        is = rs.getCharacterStream(2);
        stream = new LoopingAlphabetReader(blobLen);
        assertEquals(stream, is);

        is = rs.getCharacterStream(4);
        stream = new LoopingAlphabetReader(blobLen);
        assertEquals(stream, is);

        // clean up
        stream.close();
        is.close();
        s.close();
        rs.close();

        rollback();
View Full Code Here

            // verify that stream can be read and is right.
            verifyClob(
                clob.getCharacterStream(),
                length,
                new LoopingAlphabetReader(length));

            if (freelob)
                clob.free();
            if (commitAfterLobVerify)
                commit();
        }
        rs.close();
        commit();

        rs = ps.executeQuery();
        while (rs.next())
        {
            int  id     = rs.getInt(1);
            int  length = rs.getInt(2);

            // verify that stream can be read and is right.
            verifyClob(
                rs.getCharacterStream(3),
                length,
                new LoopingAlphabetReader(length));

            if (commitAfterLobVerify)
                commit();
        }
        rs.close();
View Full Code Here

        // insert 4 rows into "left" table containing clobs of join:
        //     (1, clob), (1, clob), (2, clob), (2, clob)
        ps.setInt(            1, 1);
        ps.setInt(            2, 40000);
        ps.setCharacterStream(3, new LoopingAlphabetReader(40000));
        ps.executeUpdate();

        ps.setInt(            1, 1);
        ps.setInt(            2, 40001);
        ps.setCharacterStream(3, new LoopingAlphabetReader(40001));
        ps.executeUpdate();

        ps.setInt(            1, 2);
        ps.setInt(            2, 40002);
        ps.setCharacterStream(3, new LoopingAlphabetReader(40002));
        ps.executeUpdate();

        ps.setInt(            1, 2);
        ps.setInt(            2, 40003);
        ps.setCharacterStream(3, new LoopingAlphabetReader(40003));
        ps.executeUpdate();
        ps.close();

        stmt.executeUpdate(
            "CREATE TABLE testMultipleClob (id int, length int, c CLOB(2M))");
        ps = conn.prepareStatement(
                "INSERT INTO testMultipleClob VALUES(?,?,?)");

        for (int i = 0; i < 100; i++)
        {
            ps.setInt(            1, i);
            ps.setInt(            2, 40000 + i);
            ps.setCharacterStream(3, new LoopingAlphabetReader(40000 + i));
            ps.executeUpdate();
        }
        ps.close();
        conn.commit();
    }
View Full Code Here

TOP

Related Classes of org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetReader

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.