Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to use setCharacterStream to update Clob in Oracle?
- String toBeUpdated = ""
- StringReader reader = new StringReader(toBeUpdated);
- pStmt.setCharacterStream(parameterIndex,reader , toBeUpdated.length());
- long id = ...
- String content = ... // CLOB content
- try {
- Class.forName ("oracle.jdbc.OracleDriver");
- Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@MY_SERVER:1521:MY_DB", "user", "pass");
- String query = "UPDATE MY_TABLE SET MY_CLOB_COLUMN = ? WHERE ID = ? ";
- OraclePreparedStatement opstmt = (OraclePreparedStatement)conn.prepareStatement(query);
- opstmt.setStringForClob(1, content);
- opstmt.setLong(2, id);
- int result = opstmt.executeUpdate();
- System.out.println("Resultado para : " + tabla + " - " + columna + " - " + id + ":" + result);
- } catch (SQLException ex) {
- //Log here
- } catch (ClassNotFoundException ex) {
- //Log here
- }
Add Comment
Please, Sign In to add comment