Package org.springframework.jdbc.core.support

# Class AbstractLobStreamingResultSetExtractor<T>

java.lang.Object
org.springframework.jdbc.core.support.AbstractLobStreamingResultSetExtractor<T>

Type Parameters:
  `T` - the result type

All Implemented Interfaces:
  `ResultSetExtractor<T>`

@Deprecated(since="6.2") public abstract class AbstractLobStreamingResultSetExtractor<T> extends Object implements ResultSetExtractor<T>
Deprecated.
as of 6.2 along with `LobHandler`, in favor of `ResultSet.getBinaryStream(int)`/`ResultSet.getCharacterStream(int)` usage
Abstract ResultSetExtractor implementation that assumes streaming of LOB data. Typically used as inner class, with access to surrounding method arguments.

Delegates to the `streamData` template method for streaming LOB content to some OutputStream, typically using a LobHandler. Converts an IOException thrown during streaming to a LobRetrievalFailureException.

A usage example with JdbcTemplate:

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);  // reusable object
     final LobHandler lobHandler = new DefaultLobHandler();  // reusable object

     jdbcTemplate.query(
               "SELECT content FROM imagedb WHERE image_name=?", new Object[] {name},
               new AbstractLobStreamingResultSetExtractor() {
                 public void streamData(ResultSet rs) throws SQLException, IOException {
             FileCopyUtils.copy(lobHandler.getBlobAsBinaryStream(rs, 1), contentStream);
           }
         });

Since:
  1.0.2
Author:
  Juergen Hoeller
See Also:
  - `LobHandler`
  - `LobRetrievalFailureException`

## Constructor Summary

Constructors
Constructor
Description
`AbstractLobStreamingResultSetExtractor()`
Deprecated.

## Method Summary

Modifier and Type
Method
Description
`final T`
`extractData(ResultSet rs)`
Deprecated.
Delegates to handleNoRowFound, handleMultipleRowsFound and streamData, according to the ResultSet state.
`protected void`
`handleMultipleRowsFound()`
Deprecated.
Handle the case where the ResultSet contains multiple rows.
`protected void`
`handleNoRowFound()`
Deprecated.
Handle the case where the ResultSet does not contain a row.
`protected abstract void`
`streamData(ResultSet rs)`
Deprecated.
Stream LOB content from the given ResultSet to some OutputStream.

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

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

## Constructor Details

### AbstractLobStreamingResultSetExtractor

public AbstractLobStreamingResultSetExtractor()
Deprecated.

## Method Details

### extractData

@Nullable public final T extractData(ResultSet rs) throws SQLException, org.springframework.dao.DataAccessException
Deprecated.
Delegates to handleNoRowFound, handleMultipleRowsFound and streamData, according to the ResultSet state. Converts an IOException thrown by streamData to a LobRetrievalFailureException.

Specified by:
  `extractData` in interface `ResultSetExtractor<T>`
Parameters:
  `rs` - the ResultSet to extract data from. Implementations should not close this: it will be closed by the calling JdbcTemplate.
Returns:
  an arbitrary result object, or `null` if none (the extractor will typically be stateful in the latter case).
Throws:
  `SQLException` - if an SQLException is encountered getting column values or navigating (that is, there's no need to catch SQLException)
  `org.springframework.dao.DataAccessException` - in case of custom exceptions
See Also:
  - `handleNoRowFound()`
  - `handleMultipleRowsFound()`
  - `streamData(java.sql.ResultSet)`
  - `LobRetrievalFailureException`

### handleNoRowFound

protected void handleNoRowFound() throws org.springframework.dao.DataAccessException
Deprecated.
Handle the case where the ResultSet does not contain a row.

Throws:
  `org.springframework.dao.DataAccessException` - a corresponding exception, by default an EmptyResultDataAccessException
See Also:
  - `EmptyResultDataAccessException`

### handleMultipleRowsFound

protected void handleMultipleRowsFound() throws org.springframework.dao.DataAccessException
Deprecated.
Handle the case where the ResultSet contains multiple rows.

Throws:
  `org.springframework.dao.DataAccessException` - a corresponding exception, by default an IncorrectResultSizeDataAccessException
See Also:
  - `IncorrectResultSizeDataAccessException`

### streamData

protected abstract void streamData(ResultSet rs) throws SQLException, IOException, org.springframework.dao.DataAccessException
Deprecated.
Stream LOB content from the given ResultSet to some OutputStream.

Typically used as inner class, with access to surrounding method arguments and to a LobHandler instance variable of the surrounding class.

Parameters:
  `rs` - the ResultSet to take the LOB content from
Throws:
  `SQLException` - if thrown by JDBC methods
  `IOException` - if thrown by stream access methods
  `org.springframework.dao.DataAccessException` - in case of custom exceptions
See Also:
  - `LobHandler.getBlobAsBinaryStream(java.sql.ResultSet, java.lang.String)`
  - `FileCopyUtils`