Abstract
PreparedStatementCallback implementation that manages a
LobCreator.
Typically used as inner class, with access to surrounding method arguments.
Delegates to the
setValues template method for setting values
on the PreparedStatement, using a given LobCreator for BLOB/CLOB arguments.
A usage example with
org.springframework.jdbc.core.JdbcTemplate:
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); // reusable object
LobHandler lobHandler = new DefaultLobHandler(); // reusable object
jdbcTemplate.execute(
"INSERT INTO imagedb (image_name, content, description) VALUES (?, ?, ?)",
new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
ps.setString(1, name);
lobCreator.setBlobAsBinaryStream(ps, 2, contentStream, contentLength);
lobCreator.setClobAsString(ps, 3, description);
}
}
);