Package org.springframework.jdbc.core.support

# Class SqlLobValue

java.lang.Object
org.springframework.jdbc.core.support.SqlLobValue

All Implemented Interfaces:
  `DisposableSqlTypeValue`, `SqlTypeValue`

@Deprecated(since="6.2") public class SqlLobValue extends Object implements DisposableSqlTypeValue
Deprecated.
as of 6.2, in favor of `SqlBinaryValue` and `SqlCharacterValue`
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. Instances of this class are stateful and immutable: use them and discard them.

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});

Since:
  1.1
Author:
  Thomas Risberg, Juergen Hoeller
See Also:
  - `LobHandler`
  - `LobCreator`
  - `JdbcTemplate.update(String, Object[], int[])`
  - `SqlUpdate.update(Object[])`
  - `StoredProcedure.execute(java.util.Map)`

## Field Summary

### Fields inherited from interface org.springframework.jdbc.core.SqlTypeValue

`TYPE_UNKNOWN`

## Constructor Summary

Constructors
Constructor
Description
`SqlLobValue(byte[] bytes)`
Deprecated.
Create a new BLOB value with the given byte array, using a DefaultLobHandler.
`SqlLobValue(byte[] bytes, LobHandler lobHandler)`
Deprecated.
Create a new BLOB value with the given byte array.
`SqlLobValue(InputStream stream, int length)`
Deprecated.
Create a new BLOB/CLOB value with the given stream, using a DefaultLobHandler.
`SqlLobValue(InputStream stream, int length, LobHandler lobHandler)`
Deprecated.
Create a new BLOB/CLOB value with the given stream.
`SqlLobValue(Reader reader, int length)`
Deprecated.
Create a new CLOB value with the given character stream, using a DefaultLobHandler.
`SqlLobValue(Reader reader, int length, LobHandler lobHandler)`
Deprecated.
Create a new CLOB value with the given character stream.
`SqlLobValue(String content)`
Deprecated.
Create a new CLOB value with the given content string, using a DefaultLobHandler.
`SqlLobValue(String content, LobHandler lobHandler)`
Deprecated.
Create a new CLOB value with the given content string.

## Method Summary

Modifier and Type
Method
Description
`void`
`cleanup()`
Deprecated.
Close the LobCreator.
`void`
`setTypeValue(PreparedStatement ps, int paramIndex, int sqlType, String typeName)`
Deprecated.
Set the specified content via the LobCreator.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SqlLobValue

public SqlLobValue(@Nullable byte[] bytes)
Deprecated.
Create a new BLOB value with the given byte array, using a DefaultLobHandler.

Parameters:
  `bytes` - the byte array containing the BLOB value
See Also:
  - `DefaultLobHandler`

### SqlLobValue

public SqlLobValue(@Nullable byte[] bytes, LobHandler lobHandler)
Deprecated.
Create a new BLOB value with the given byte array.

Parameters:
  `bytes` - the byte array containing the BLOB value
  `lobHandler` - the LobHandler to be used

### SqlLobValue

public SqlLobValue(@Nullable String content)
Deprecated.
Create a new CLOB value with the given content string, using a DefaultLobHandler.

Parameters:
  `content` - the String containing the CLOB value
See Also:
  - `DefaultLobHandler`

### SqlLobValue

public SqlLobValue(@Nullable String content, LobHandler lobHandler)
Deprecated.
Create a new CLOB value with the given content string.

Parameters:
  `content` - the String containing the CLOB value
  `lobHandler` - the LobHandler to be used

### SqlLobValue

public SqlLobValue(InputStream stream, int length)
Deprecated.
Create a new BLOB/CLOB value with the given stream, using a DefaultLobHandler.

Parameters:
  `stream` - the stream containing the LOB value
  `length` - the length of the LOB value
See Also:
  - `DefaultLobHandler`

### SqlLobValue

public SqlLobValue(InputStream stream, int length, LobHandler lobHandler)
Deprecated.
Create a new BLOB/CLOB value with the given stream.

Parameters:
  `stream` - the stream containing the LOB value
  `length` - the length of the LOB value
  `lobHandler` - the LobHandler to be used

### SqlLobValue

public SqlLobValue(Reader reader, int length)
Deprecated.
Create a new CLOB value with the given character stream, using a DefaultLobHandler.

Parameters:
  `reader` - the character stream containing the CLOB value
  `length` - the length of the CLOB value
See Also:
  - `DefaultLobHandler`

### SqlLobValue

public SqlLobValue(Reader reader, int length, LobHandler lobHandler)
Deprecated.
Create a new CLOB value with the given character stream.

Parameters:
  `reader` - the character stream containing the CLOB value
  `length` - the length of the CLOB value
  `lobHandler` - the LobHandler to be used

## Method Details

### setTypeValue

public void setTypeValue(PreparedStatement ps, int paramIndex, int sqlType, @Nullable String typeName) throws SQLException
Deprecated.
Set the specified content via the LobCreator.

Specified by:
  `setTypeValue` in interface `SqlTypeValue`
Parameters:
  `ps` - the PreparedStatement to work on
  `paramIndex` - the index of the parameter for which we need to set the value
  `sqlType` - the SQL type of the parameter we are setting
  `typeName` - the type name of the parameter (optional)
Throws:
  `SQLException` - if an SQLException is encountered while setting parameter values
See Also:
  - `Types`
  - `PreparedStatement.setObject(int, java.lang.Object, int)`

### cleanup

public void cleanup()
Deprecated.
Close the LobCreator.

Specified by:
  `cleanup` in interface `DisposableSqlTypeValue`
See Also:
  - `cleanup()`
  - `SqlValue.cleanup()`