Java JDBC Clob create and insert
import java.sql.Clob; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class Main { public static void loadClob(Connection conn) { PreparedStatement pstmt = null; String sql = null;/*from w w w . j a va2 s .c o m*/ Clob textClob = null; try { textClob = conn.createClob(); textClob.setString(1, "clob test"); sql = "INSERT INTO RECIPE_TEXT VALUES(" + "?, " + "?)"; pstmt = conn.prepareStatement(sql); pstmt.setInt(1, 1); // set the clob value pstmt.setClob(2, textClob); pstmt.executeUpdate(); } catch (SQLException ex) { ex.printStackTrace(); } finally { if (pstmt != null) { try { pstmt.close(); } catch (SQLException ex) { ex.printStackTrace(); } } if (textClob != null) { try { textClob.free(); } catch (SQLException ex) { ex.printStackTrace(); } } } } }