//
JDBCClob dataClob =
new JDBCClob("the quick brown fox jumps on the lazy dog");
Reader reader = null;
StopWatch sw = new StopWatch();
sw.start();
for (int i = 0; i < 100; i++) {
reader = dataClob.getCharacterStream();
ps.setString(1, "test-id-1" + i);
ps.setLong(2, 23456789123456L + i);
ps.setCharacterStream(3, reader, dataClob.length());
ps.setString(4, "test-scope-1" + i);
ps.executeUpdate();
connection.commit();
}
sw.stop();
System.out.println(sw.elapsedTimeToMessage("Time for inserts"));
ps = connection.prepareStatement(dml1);
sw.zero();
sw.start();
for (int i = 10; i < 20; i++) {
ps.setString(1, "test-id-1" + i);
ps.setLong(2, 23456789123456L + i);
ps.setString(3, "test-scope-1" + i);
ps.executeUpdate();
connection.commit();
}
connection.commit();
ResultSet rs = statement.executeQuery("SELECT * FROM VARIABLE");
while (rs.next()) {
Clob clob = rs.getClob(4);
long dataLength = dataClob.length();
long clobLength = clob.length();
assertTrue(dataLength == clobLength);
assertTrue(
dataClob.getSubString(1, 30).equals(
clob.getSubString(1, 30)));
}
rs = statement.executeQuery(
"SELECT CAST(SUBSTRING(VALUE FROM 19) AS VARCHAR(100)),STATEID,"
+ "CHARACTER_LENGTH(VALUE),CAST(VALUE AS VARCHAR(100)) FROM "
+ "VARIABLE WHERE VALUE='THE QUICK BROWN FOX JUMPS ON THE LAZY DOG'"
+ "AND STATEID>'TEST-ID-197'");
while (rs.next()) {
assertTrue(rs.getString(1).equals("x jumps on the lazy dog"));
}
sw.stop();
System.out.println(sw.elapsedTimeToMessage("Time for updates"));
} catch (SQLException e) {
e.printStackTrace();
fail("test failure");
}
}