Top Description Methods
org.springframework.jdbc.core

public Interface ResultSetExtractor<T>

Known Direct Implementers
org.springframework.jdbc.core.RowMapperResultSetExtractor, org.springframework.jdbc.core.SqlRowSetResultSetExtractor, org.springframework.jdbc.core.support.AbstractLobStreamingResultSetExtractor, org.springframework.jdbc.core.JdbcTemplate.RowCallbackHandlerResultSetExtractor
Annotations
@FunctionalInterface
Type Parameters
<T>
the result type
Imports
java.sql.ResultSet, .SQLException, org.springframework.dao.DataAccessException, org.springframework.lang.Nullable

Callback interface used by JdbcTemplate's query methods. Implementations of this interface perform the actual work of extracting results from a java.sql.ResultSet, but don't need to worry about exception handling. SQLExceptions will be caught and handled by the calling JdbcTemplate.

This interface is mainly used within the JDBC framework itself. A RowMapper is usually a simpler choice for ResultSet processing, mapping one result object per row instead of one result object for the entire ResultSet.

Note

In contrast to a RowCallbackHandler, a ResultSetExtractor object is typically stateless and thus reusable, as long as it doesn't access stateful resources (such as output streams when streaming LOB contents) or keep result state within the object.

Authors
Rod Johnson, Juergen Hoeller
Since
April 24, 2003
See Also
JdbcTemplate, RowCallbackHandler, RowMapper, org.springframework.jdbc.core.support.AbstractLobStreamingResultSetExtractor

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

an arbitrary result object, or null if none (the extractor will typically be stateful in the latter case).
extractData
(ResultSet
the ResultSet to extract data from. Implementations should not close this: it will be closed by the calling JdbcTemplate.
rs
)

Implementations must implement this method to process the entire ResultSet.

Method Detail

extractDataback to summary
public T extractData(ResultSet rs) throws SQLException, DataAccessException

Implementations must implement this method to process the entire ResultSet.

Parameters
rs:ResultSet

the ResultSet to extract data from. Implementations should not close this: it will be closed by the calling JdbcTemplate.

Returns:T

an arbitrary result object, or null if none (the extractor will typically be stateful in the latter case).

Annotations
@Nullable
Exceptions
SQLException:
if an SQLException is encountered getting column values or navigating (that is, there's no need to catch SQLException)
DataAccessException:
in case of custom exceptions