I put the json as a String and created this method, it worked for me:
public long insertClob(String id, String json ) {
KeyHolder holder = new GeneratedKeyHolder();
jdbcTemplate.update(new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
PreparedStatement ps = connection.prepareStatement("UPDATE tableWithClobColumn SET clobColumn=? WHERE id=?",
Statement.RETURN_GENERATED_KEYS);
Reader reader = new StringReader(json);
ps.setClob(1, reader);
ps.setString(2, "1911030604");
return ps;
}
}, holder);
return Long.parseLong("0");
}
JSONObjector a JSONStringand insert the text?preparedStatement.setString(1, json_obj.toString());I get SQL error: 1036 ORA-01036: illegal variable name/numbertoJSONStringinstead oftoStringso you get the actual JSON structuretoJSONStringgives same SQL error: 1036 ORA-01036: illegal variable name/number. As suggested in above link triedoracle.sql.CLOB.createTemporary(conn, false, oracle.sql.CLOB.DURATION_SESSION);which gives org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper cannot be cast to oracle.jdbc.OracleConnection. I believe there should be an easier way.