On fre, 2005-09-16 at 02:33, firstname lastname wrote:
> I need a simple but complete example of how to insert a CLOB into derby
> via jdbc.
> Any help would be appreciated.
public static void setClobMaxLength(PreparedStatement s, int
fieldNum,
String contents, long maxSize,
Object o, String fieldName)
throws SQLException {
if (contents != null) {
if (contents.length() > maxSize) {
throw new PermissionDenied(fieldName + " of " + o
+ " is longer than " + maxSize + " characters");
}
s.setCharacterStream(fieldNum, new StringReader(contents),
contents.length());
s.setString(fieldNum, contents);
} else {
s.setNull(fieldNum, Types.CLOB);
}
}
Here's how you set the contents. The rest is identical to inserting
other things.
-Lars