Examples of LoopingAlphabetReader


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

     */
    private void getCharacterStreamLongLastChar(int id, int length,
                                                CharAlphabet alphabet)
            throws IOException, SQLException {
        // Get last char from the source stream.
        Reader cmpReader = new LoopingAlphabetReader(length, alphabet);
        cmpReader.skip(length -1);
        char srcLastChar = (char)cmpReader.read();
        assertTrue(cmpReader.read() == -1);

        PreparedStatement ps = prepareStatement(
                "select CLOBDATA from BLOBCLOB where ID=?");
        ps.setInt(1, id);
        // Read everything first.
View Full Code Here

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

            throws IOException, SQLException {
        PreparedStatement ps = prepareStatement(
                "insert into BLOBCLOB(ID, CLOBDATA) values(?,?)");
        int id = BlobClobTestSetup.getID();
        ps.setInt(1, id);
        ps.setCharacterStream(2, new LoopingAlphabetReader(length), length);
        long tsStart = System.currentTimeMillis();
        ps.execute();
        println("Inserted " + length + " chars (length specified) in " +
                (System.currentTimeMillis() - tsStart) + " ms");
        Statement stmt = createStatement();
        tsStart = System.currentTimeMillis();
        ResultSet rs = stmt.executeQuery(
                "select CLOBDATA from BLOBCLOB where id = " + id);
        assertTrue("Clob not inserted", rs.next());
        Clob aClob = rs.getClob(1);
        assertEquals("Invalid length", length, aClob.length());
        println("Fetched length (" + length + ") in " +
                (System.currentTimeMillis() - tsStart) + " ms");
        rs.close();

        // Insert same Clob again, using the lengthless override.
        id = BlobClobTestSetup.getID();
        ps.setInt(1, id);
        ps.setCharacterStream(2, new LoopingAlphabetReader(length));
        tsStart = System.currentTimeMillis();
        ps.executeUpdate();
        println("Inserted " + length + " chars (length unspecified) in " +
                (System.currentTimeMillis() - tsStart) + " ms");
        rs = stmt.executeQuery(
View Full Code Here

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

        // Insert a long Clob
        PreparedStatement ps = prepareStatement(
                "insert into BLOBCLOB(ID, CLOBDATA) values(?,?)");
        int id = BlobClobTestSetup.getID();
        ps.setInt(1,id);
        ps.setCharacterStream(2, new LoopingAlphabetReader(lobLength), lobLength);
        ps.execute();
        ps.close();
        commit();

        // Fetch the Clob object from the database
View Full Code Here

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

        int clobLength = 5009;

        // insert a streaming column
        PreparedStatement ps = prepareStatement(
                "insert into testClob (a) values(?)");
        Reader streamReader = new LoopingAlphabetReader(
                clobLength, CharAlphabet.tamil());
        ps.setCharacterStream(1, streamReader, clobLength);
        ps.executeUpdate();
        streamReader.close();
        ps.close();
        commit();

        Statement stmt = createStatement();
        ResultSet rs = stmt.executeQuery("SELECT a FROM testClob");
        while (rs.next()) {
            Clob clob = rs.getClob(1);
            assertEquals("FAIL - wrong clob length", clobLength, clob.length());
            Reader clobValue = clob.getCharacterStream();
            Reader origValue = new LoopingAlphabetReader(
                    clobLength, CharAlphabet.tamil());

            assertTrue("New clob value did not match",
                    compareReaders(origValue, clobValue));
            origValue.close();
            clobValue.close();
        }
        rs.close();
        stmt.close();
View Full Code Here

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

                            unicodeStrings[arrayIndex],
                            new String(buff));
                    assertEquals("Expected end of stream",
                            -1, clobValue.read());
                } else {
                    Reader origValue = new LoopingAlphabetReader(
                            clobLength, CharAlphabet.tamil());
                    compareReaders(origValue, clobValue);
                }
            } else {
                assertTrue("Clob was null but length was not 0",
View Full Code Here

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

        getConnection().setAutoCommit(false);

        PreparedStatement ps = prepareStatement(
                "insert into testClob(b, a) values(?,?)");
        for (int i = 0; i < 3; i++) {
            Reader fis = new LoopingAlphabetReader(300000);
            ps.setInt(1, i);
            ps.setCharacterStream(2, fis, 300000);
            ps.executeUpdate();
            fis.close();
        }
        commit();

        getConnection().setAutoCommit(true);
View Full Code Here

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

            PreparedStatement ps,
            CharAlphabet alphabet,
            int lobLength)
        throws Exception
    {
        ps.setCharacterStream(1, new LoopingAlphabetReader(lobLength, alphabet),
                lobLength);
        ps.setInt(2, lobLength);
        ps.setLong(3, -1);
        ps.executeUpdate();
    }
View Full Code Here

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

        stmt.executeUpdate("CREATE TABLE testLob " +
                " (c clob(" + clobSize + "))");
        stmt.close();
        PreparedStatement ps =
                prepareStatement("insert into testLob values(?)");
        Reader reader = new LoopingAlphabetReader(clobSize);
        ps.setCharacterStream(1, reader, clobSize);
        ps.executeUpdate();
        ps.close();
    }
View Full Code Here

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

     * @param pos 1-based Clob position
     * @param clob internal store stream Clob representation
     */
    private static void checkInternalStream(long pos, StoreStreamClob clob)
            throws IOException, SQLException {
        Reader canonStream = new LoopingAlphabetReader(pos + 100);
        long toSkip = pos -1; // Convert to 0-based index.
        while (toSkip > 0) {
            long skipped = canonStream.skip(toSkip);
            if (skipped > 0) {
                toSkip -= skipped;
            }
        }
        Reader clobStream = clob.getInternalReader(pos);
        assertEquals("Data mismatch", canonStream.read(), clobStream.read());
        clobStream.close();
    }
View Full Code Here

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

                "insert into Utf8ReaderTest values (?,?,?)");
        for (int i=0; i < sizes.length; i++) {
            ps.setInt(1, sizes[i][0]);
            int size = sizes[i][1];
            ps.setInt(2, size);
            ps.setCharacterStream(3, new LoopingAlphabetReader(size), size);
            ps.executeUpdate();
        }
       
        // Insert some special pieces of text, repeat to get it represented as
        // a stream.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.