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();