Java Reference
In-Depth Information
+ "?)";
try (PreparedStatement pstmt
= conn.prepareStatement(sql);) {
textClob = conn.createClob();
textClob.setString(1, "This will be the
recipe text in clob format");
// obtain the sequence number in real world
// set the clob value
pstmt.setClob(1, textClob);
pstmt.executeUpdate();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
public static void readClob() {
String qry = "select text from recipe_text";
Clob theClob = null;
try(PreparedStatement pstmt
= conn.prepareStatement(qry);
ResultSet rs = pstmt.executeQuery();) {
while (rs.next()) {
theClob = rs.getClob(1);
System.out.println("Clob length: "
+ theClob.length());
System.out.println(theClob.toString());
}
System.out.println(theClob.toString());
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
Search WWH ::




Custom Search