views:

4

answers:

0

Here's a bit of example code from the spring doc. Note that it passes the length of the clob and blob data to the lobCreator.

What if I don't know the length? Do I have any choices save to buffer?

jdbcTemplate.execute(
  "INSERT INTO lob_table (id, a_clob, a_blob) VALUES (?, ?, ?)",
  new AbstractLobCreatingPreparedStatementCallback(lobHandler) {                                                       
      protected void setValues(PreparedStatement ps, LobCreator lobCreator) 
          throws SQLException {
        ps.setLong(1, 1L);
        lobCreator.setClobAsCharacterStream(ps, 2, clobReader, (int)clobIn.length());                                  
        lobCreator.setBlobAsBinaryStream(ps, 3, blobIs, (int)blobIn.length());                                         
      }
  }
);