open class SqlLobValue : DisposableSqlTypeValue
Object to represent an SQL BLOB/CLOB value parameter. BLOBs can either be an InputStream or a byte array. CLOBs can be in the form of a Reader, InputStream or String. Each CLOB/BLOB value will be stored together with its length. The type is based on which constructor is used. Objects of this class are immutable except for the LobCreator reference. Use them and discard them.
This class holds a reference to a LocCreator that must be closed after the update has completed. This is done via a call to the closeLobCreator 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});
Author
Thomas Risberg
Author
Juergen Hoeller
Since
1.1
See Also
org.springframework.jdbc.support.lob.LobHandlerorg.springframework.jdbc.support.lob.LobCreatororg.springframework.jdbc.core.JdbcTemplate#update(String, Object[], int[])org.springframework.jdbc.object.SqlUpdate#update(Object[])org.springframework.jdbc.object.StoredProcedure#execute(java.util.Map)
SqlLobValue(bytes: ByteArray)
Create a new BLOB value with the given byte array, using a DefaultLobHandler. SqlLobValue(bytes: ByteArray, lobHandler: LobHandler)
Create a new BLOB value with the given byte array. SqlLobValue(content: String)
Create a new CLOB value with the given content string, using a DefaultLobHandler. SqlLobValue(content: String, lobHandler: LobHandler)
Create a new CLOB value with the given content string. SqlLobValue(stream: InputStream, length: Int)
Create a new BLOB/CLOB value with the given stream, using a DefaultLobHandler. SqlLobValue(stream: InputStream, length: Int, lobHandler: LobHandler)
Create a new BLOB/CLOB value with the given stream. SqlLobValue(reader: Reader, length: Int)
Create a new CLOB value with the given character stream, using a DefaultLobHandler. SqlLobValue(reader: Reader, length: Int, lobHandler: LobHandler)
Create a new CLOB value with the given character stream. |
open fun cleanup(): Unit
Close the LobCreator, if any. |
|
open fun setTypeValue(ps: PreparedStatement, paramIndex: Int, sqlType: Int, typeName: String): Unit
Set the specified content via the LobCreator. |