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);
//DERBY-4312 make sure commit() doesn't interfere
commit();
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();