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

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


                "select dClob, length from largeClobs where id = 5");
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            Clob clob = rs.getClob(1);
            int remaining = rs.getInt(2);
            Reader myReader = new LoopingAlphabetReader(remaining);
            if (modifyClob) {
                // Modify the Clob to create a temporary copy in memory or on
                // disk (depends on the Clob size).
                long modifyStart = System.currentTimeMillis();
                clob.setString(++remaining, "X");
                println("Clob modification duration: " +
                        (System.currentTimeMillis() - modifyStart) + " ms");
            }
            Reader clobReader = clob.getCharacterStream();
            char[] buf = new char[MAX_BSIZE];
            while (remaining > 0) {
                int read = clobReader.read(buf, 0, Math.min(MAX_BSIZE, remaining));
                myReader.skip(read -1);
                remaining -= read;
                assertEquals(myReader.read(), buf[read -1]);
            }
        }
        rs.close();
       
    }
View Full Code Here


            // Insert some large Clobs.
            final int size = largeClobSizeMB*1024*1024; // 15 MB default
            for (int clobCounter = 1; clobCounter < 11; clobCounter++) {
                largeClobInsert.setInt(1, clobCounter);
                largeClobInsert.setCharacterStream(
                        2, new LoopingAlphabetReader(size), size);
                largeClobInsert.setInt(3, size);
                largeClobInsert.executeUpdate();
                println("Inserted large Clob #" + (clobCounter -1));
            }
            con.commit();
View Full Code Here

                "c2 = c2 + 1 WHERE c1 IN (?, ?)");
        switch (testVariation) {
        case 1 :
          //test short data
            ps.setCharacterStream(1,
                    new LoopingAlphabetReader(50, a1), 50);
            break;
        case 2 :
          //test large data
          if (testCLOB) {
            //for CLOB column, use 50K data
                ps.setCharacterStream(1,
                        new LoopingAlphabetReader(50000, a1), 50000);
          } else {
            //for VARCHAR column, use 32K data
              ps.setCharacterStream(1,
                      new LoopingAlphabetReader(32000, a1), 32000);
          }
            break;
        }

        //First value in IN clause is getting set to 'AAAAA'
View Full Code Here

        getConnection().setAutoCommit(false);
        int length = 266000;
        PreparedStatement ps = prepareStatement(
                "insert into updateClob (id, data) values (?,?)");
        ps.setInt(1, length);
        ps.setCharacterStream(2, new LoopingAlphabetReader(length), length);
        assertEquals(1, ps.executeUpdate());
        ps.close();
        PreparedStatement psFetchClob = prepareStatement(
                "select data from updateClob where id = ?");
        psFetchClob.setInt(1, length);
View Full Code Here

       
        ps.setString(1, clobSize +"");

        // - set the value of the input parameter to the input stream
        ps.setCharacterStream(2,
                new LoopingAlphabetReader(clobSize, a1), clobSize);
        ps.execute();
        closeStatement(ps);
        commit();

        // Now executing update to fire trigger
        s.executeUpdate("update LOB1 set str1 = str1 || ' '");
      
       
        s.executeUpdate("drop table lob1");
        s.executeUpdate("drop table t_lob1_log");

        // now referencing the lob column
        trig = " create trigger t_lob1 after update of c_lob on lob1 ";
        trig = trig + " REFERENCING OLD AS old NEW AS new FOR EACH ROW MODE DB2SQL ";
        trig = trig + " insert into t_lob1_log(oldvalue, newvalue) values (old.c_lob, new.c_lob)";

        s.executeUpdate("create table LOB1 (str1 Varchar(80), c_lob CLOB(50M))");
        s.executeUpdate("create table t_lob1_log(oldvalue CLOB(50M), newvalue  CLOB(50M), chng_time timestamp default current_timestamp)");
        s.executeUpdate(trig);
        commit();     

        ps = prepareStatement("INSERT INTO LOB1 VALUES (?, ?)");
       
        ps.setString(1, clobSize +"");

        // - set the value of the input parameter to the input stream
        ps.setCharacterStream(2,
                new LoopingAlphabetReader(clobSize, a1), clobSize);
        ps.execute();
        closeStatement(ps);
        commit();

        // Now executing update to fire trigger
        ps = prepareStatement("update LOB1 set c_lob = ?");
        ps.setCharacterStream(1,
                new LoopingAlphabetReader(clobSize, a2), clobSize);
        ps.execute();
        closeStatement(ps);
        commit();       

        s.executeUpdate("drop table lob1");
        s.executeUpdate("drop table t_lob1_log");
       
        //      now referencing the lob column twice
        trig = " create trigger t_lob1 after update of c_lob on lob1 ";
        trig = trig + " REFERENCING OLD AS old NEW AS new FOR EACH ROW MODE DB2SQL ";
        trig = trig + " insert into t_lob1_log(oldvalue, newvalue, oldvalue_again, newvalue_again) values (old.c_lob, new.c_lob, old.c_lob, new.c_lob)";

        s.executeUpdate("create table LOB1 (str1 Varchar(80), c_lob CLOB(50M))");
        s.executeUpdate("create table t_lob1_log(oldvalue CLOB(50M), newvalue  CLOB(50M), oldvalue_again CLOB(50M), newvalue_again CLOB(50M), chng_time timestamp default current_timestamp)");
        s.executeUpdate(trig);
        commit();     

        ps = prepareStatement("INSERT INTO LOB1 VALUES (?, ?)");
       
        ps.setString(1, clobSize +"");

        // - set the value of the input parameter to the input stream
        ps.setCharacterStream(2,
                new LoopingAlphabetReader(clobSize, a1), clobSize);
        ps.execute();
        closeStatement(ps);
        commit();

        // Now executing update to fire trigger
        ps = prepareStatement("update LOB1 set c_lob = ?");
        ps.setCharacterStream(1,
                new LoopingAlphabetReader(clobSize, a2), clobSize);
        ps.execute();
        closeStatement(ps);
        commit();
       
        // check log table.
        ResultSet rs = s.executeQuery("SELECT * from t_lob1_log");
        rs.next();
              
        assertEquals(new LoopingAlphabetReader(clobSize, a1),
                     rs.getCharacterStream(1));

        assertEquals(new LoopingAlphabetReader(clobSize, a2),
                     rs.getCharacterStream(2));

        assertEquals(new LoopingAlphabetReader(clobSize, a1),
                     rs.getCharacterStream(3));

        assertEquals(new LoopingAlphabetReader(clobSize, a2),
                     rs.getCharacterStream(4));

        rs.close();
       
        s.executeUpdate("drop table lob1");
View Full Code Here

        ps.setString(1, clobSize +"");


        // - set the value of the input parameter to the input stream
        ps.setCharacterStream(2,
                new LoopingAlphabetReader(clobSize, a1), clobSize);
        ps.execute();
        conn.commit();


        PreparedStatement ps2 = prepareStatement("update LOB1 set c_lob = ? where str1 = '" + clobSize + "'");
        ps2.setCharacterStream(1,
                new LoopingAlphabetReader(clobSize, a2), clobSize);
        ps2.executeUpdate();
        conn.commit();
        //   --- reading the clob make sure it was updated
        ResultSet rs = s.executeQuery("SELECT * FROM LOB1 where str1 = '" + clobSize + "'");
        rs.next();
       
        assertEquals(new LoopingAlphabetReader(clobSize, a2),
                     rs.getCharacterStream(2));
        rs.close();
        s.executeUpdate("drop table lob1");
        s.executeUpdate("drop table t_lob1_log");
       
View Full Code Here

        int vcSize = 32672;
        int limit = 10;
        PreparedStatement ps = prepareStatement(
                "insert into setMaxFieldSize values (?,?,?)");
        ps.setInt(1, id);
        ps.setCharacterStream(2, new LoopingAlphabetReader(vcSize), vcSize);
        ps.setCharacterStream(3, new LoopingAlphabetReader(clobSize), clobSize);
        ps.executeUpdate();

        // Fetch data back with a limit.
        Statement stmt = createStatement();
        stmt.setMaxFieldSize(limit);
View Full Code Here

                "c2 = c2 + 1 WHERE c1 IN (?, ?)");
        switch (testVariation) {
        case 1 :
          //test short data
            ps.setCharacterStream(1,
                    new LoopingAlphabetReader(50, a1), 50);
            break;
        case 2 :
          //test large data
          if (testCLOB) {
            //for CLOB column, use 50K data
                ps.setCharacterStream(1,
                        new LoopingAlphabetReader(50000, a1), 50000);
          } else {
            //for VARCHAR column, use 32K data
              ps.setCharacterStream(1,
                      new LoopingAlphabetReader(32000, a1), 32000);
          }
            break;
        }

        //First value in IN clause is getting set to 'AAAAA'
View Full Code Here

                 int mpSize = 173*1024; // 173 KB or KChars
                 int spSize = 300; // 300 B or chars
                 ps.setBinaryStream(1,
                         new LoopingAlphabetStream(mpSize), mpSize);
                 ps.setCharacterStream(2,
                         new LoopingAlphabetReader(mpSize), mpSize);
                 ps.executeUpdate();
                 ps.setBinaryStream(1,
                         new LoopingAlphabetStream(spSize), spSize);
                 ps.setCharacterStream(2,
                         new LoopingAlphabetReader(spSize), spSize);
                 ps.executeUpdate();
                 ps.setNull(1, Types.BLOB);
                 ps.setNull(2, Types.CLOB);
                 ps.executeUpdate();
                 // Make sure there are three rows.
View Full Code Here

        // Make a lob table and insert one row
        s.executeUpdate("create table lobtable(i int, c clob)");
        PreparedStatement ps = prepareStatement(
            "insert into lobtable values (1,?)");
        ps.setCharacterStream(
            1, new LoopingAlphabetReader(1000), 1000);
        ps.executeUpdate();

        // Export the lob table
        s.executeUpdate("call SYSCS_UTIL.SYSCS_EXPORT_TABLE_LOBS_TO_EXTFILE(" +
                        "    'SYS'," +
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.