PreparedStatement ps =
c.prepareStatement("INSERT INTO " + tableName +
"(ID, TEXT" + extraCols +
") VALUES (?, ?" + extraParams + ")");
UniqueRandomSequence secIdSequence = null;
if (withSecIndexColumn) {
secIdSequence = new UniqueRandomSequence(tableSize);
}
UniqueRandomSequence nonIndexedSequence = null;
if (withNonIndexedColumn) {
nonIndexedSequence = new UniqueRandomSequence(tableSize);
}
for (int i = 0; i < tableSize; i++) {
int col = 1;
ps.setInt(col++, i);
if (dataType == Types.VARCHAR) {
ps.setString(col++, randomString(i));
} else if (dataType == Types.CLOB) {
StringReader reader = new StringReader(randomString(i));
ps.setCharacterStream(col++, reader, TEXT_SIZE);
} else if (dataType == Types.BLOB) {
ByteArrayInputStream stream =
new ByteArrayInputStream(randomBytes(i));
ps.setBinaryStream(col++, stream, TEXT_SIZE);
}
if (withSecIndexColumn) {
ps.setInt(col++, secIdSequence.nextValue());
}
if (withNonIndexedColumn) {
ps.setInt(col++, nonIndexedSequence.nextValue());
}
ps.executeUpdate();
if ((i % 1000) == 0) {
c.commit();
}