NOTE: As of 6.1.4, this class is effectively superseded by
SqlBinaryValue and SqlCharacterValue which are capable of
modern BLOB/CLOB handling while also handling LONGVARBINARY/LONGVARCHAR.
The only reason to keep using this class is a custom LobHandler.
This class holds a reference to a LobCreator that must be closed after
the update has completed. This is done via a call to the cleanup() method.
All handling of the LobCreator is done by the framework classes that use it -
no need to set or close the LobCreator for end users of this class.
A usage example:
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); // reusable object
LobHandler lobHandler = new DefaultLobHandler(); // reusable object
jdbcTemplate.update(
"INSERT INTO imagedb (image_name, content, description) VALUES (?, ?, ?)",
new Object[] {
name,
new SqlLobValue(contentStream, contentLength, lobHandler),
new SqlLobValue(description, lobHandler)
},
new int[] {Types.VARCHAR, Types.BLOB, Types.CLOB});
org.springframework.jdbc.support.lob.LobHandler , org.springframework.jdbc.support.lob.LobCreator , org.springframework.jdbc.core.JdbcTemplate#update(String, Object[], int[]) , org.springframework.jdbc.object.SqlUpdate#update(Object[]) , org.springframework.jdbc.object.StoredProcedure#execute(java.util.Map)
| Modifier and Type | Field and Description |
|---|---|
| private final Object | |
| private final int | |
| private final LobCreator | lobCreator
Reference to the LobCreator - so we can close it once the update is done. |
| Access | Constructor and Description |
|---|---|
| public | SqlLobValue(byte[]
the byte array containing the BLOB value bytes)Create a new BLOB value with the given byte array, using a DefaultLobHandler. |
| public | SqlLobValue(byte[]
the byte array containing the BLOB value bytes, LobHandler the LobHandler to be used lobHandler)Create a new BLOB value with the given byte array. |
| public | SqlLobValue(String
the String containing the CLOB value content)Create a new CLOB value with the given content string, using a DefaultLobHandler. |
| public | SqlLobValue(String
the String containing the CLOB value content, LobHandler the LobHandler to be used lobHandler)Create a new CLOB value with the given content string. |
| public | SqlLobValue(InputStream
the stream containing the LOB value stream, int the length of the LOB value length)Create a new BLOB/CLOB value with the given stream, using a DefaultLobHandler. |
| public | SqlLobValue(InputStream
the stream containing the LOB value stream, int the length of the LOB value length, LobHandler the LobHandler to be used lobHandler)Create a new BLOB/CLOB value with the given stream. |
| public | SqlLobValue(Reader
the character stream containing the CLOB value reader, int the length of the CLOB value length)Create a new CLOB value with the given character stream, using a DefaultLobHandler. |
| public | SqlLobValue(Reader
the character stream containing the CLOB value reader, int the length of the CLOB value length, LobHandler the LobHandler to be used lobHandler)Create a new CLOB value with the given character stream. |
| Modifier and Type | Method and Description |
|---|---|
| public void | cleanup()
Implements org. Close the LobCreator. |
| public void | setTypeValue(PreparedStatement
the PreparedStatement to work on ps, int the index of the parameter for which we need to set the value paramIndex, int the SQL type of the parameter we are setting sqlType, String the type name of the parameter (optional) typeName)Implements org. Set the specified content via the LobCreator. |
| content | back to summary |
|---|---|
| private final Object content
| |
| length | back to summary |
|---|---|
| private final int length | |
| lobCreator | back to summary |
|---|---|
| private final LobCreator lobCreator Reference to the LobCreator - so we can close it once the update is done. | |
| SqlLobValue | back to summary |
|---|---|
| public SqlLobValue(byte[] bytes) Create a new BLOB value with the given byte array, using a DefaultLobHandler.
| |
| SqlLobValue | back to summary |
|---|---|
| public SqlLobValue(byte[] bytes, LobHandler lobHandler) Create a new BLOB value with the given byte array.
| |
| SqlLobValue | back to summary |
|---|---|
| public SqlLobValue(String content) Create a new CLOB value with the given content string, using a DefaultLobHandler.
| |
| SqlLobValue | back to summary |
|---|---|
| public SqlLobValue(String content, LobHandler lobHandler) Create a new CLOB value with the given content string.
| |
| SqlLobValue | back to summary |
|---|---|
| public SqlLobValue(InputStream stream, int length) Create a new BLOB/CLOB value with the given stream, using a DefaultLobHandler.
| |
| SqlLobValue | back to summary |
|---|---|
| public SqlLobValue(InputStream stream, int length, LobHandler lobHandler) Create a new BLOB/CLOB value with the given stream.
| |
| SqlLobValue | back to summary |
|---|---|
| public SqlLobValue(Reader reader, int length) Create a new CLOB value with the given character stream, using a DefaultLobHandler.
| |
| SqlLobValue | back to summary |
|---|---|
| public SqlLobValue(Reader reader, int length, LobHandler lobHandler) Create a new CLOB value with the given character stream.
| |
| cleanup | back to summary |
|---|---|
| public void cleanup() Implements org. Close the LobCreator.
| |
| setTypeValue | back to summary |
|---|---|
| public void setTypeValue(PreparedStatement ps, int paramIndex, int sqlType, String typeName) throws SQLException Implements org. Set the specified content via the LobCreator.
| |