接口 ResultSetExtractor<T>
- 类型参数:
T
- the result type
- 所有已知实现类:
AbstractLobStreamingResultSetExtractor
,RowMapperResultSetExtractor
,SqlRowSetResultSetExtractor
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
@FunctionalInterface public interface ResultSetExtractor<T>
Callback interface used byJdbcTemplate
's query methods. Implementations of this interface perform the actual work of extracting results from aResultSet
, 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.- 从以下版本开始:
- April 24, 2003
- 作者:
- Rod Johnson, Juergen Hoeller
- 另请参阅:
JdbcTemplate
,RowCallbackHandler
,RowMapper
,AbstractLobStreamingResultSetExtractor
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 T
extractData(ResultSet rs)
Implementations must implement this method to process the entire ResultSet.
方法详细资料
extractData
@Nullable T extractData(ResultSet rs) throws SQLException, DataAccessException
Implementations must implement this method to process the entire ResultSet.- 参数:
rs
- the ResultSet to extract data from. Implementations should not close this: it will be closed by the calling JdbcTemplate.- 返回:
- an arbitrary result object, or
null
if none (the extractor will typically be stateful in the latter case). - 抛出:
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