接口 RowCallbackHandler
- 所有已知实现类:
RowCountCallbackHandler
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
@FunctionalInterface public interface RowCallbackHandler
An interface used byJdbcTemplate
for processing rows of aResultSet
on a per-row basis. Implementations of this interface perform the actual work of processing each row but don't need to worry about exception handling.SQLExceptions
will be caught and handled by the calling JdbcTemplate.In contrast to a
ResultSetExtractor
, a RowCallbackHandler object is typically stateful: It keeps the result state within the object, to be available for later inspection. SeeRowCountCallbackHandler
for a usage example.Consider using a
RowMapper
instead if you need to map exactly one result object per row, assembling them into a List.- 作者:
- Rod Johnson, Juergen Hoeller
- 另请参阅:
JdbcTemplate
,RowMapper
,ResultSetExtractor
,RowCountCallbackHandler
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 void
processRow(ResultSet rs)
Implementations must implement this method to process each row of data in the ResultSet.
方法详细资料
processRow
void processRow(ResultSet rs) throws SQLException
Implementations must implement this method to process each row of data in the ResultSet. This method should not callnext()
on the ResultSet; it is only supposed to extract values of the current row.Exactly what the implementation chooses to do is up to it: A trivial implementation might simply count rows, while another implementation might build an XML document.
- 参数:
rs
- the ResultSet to process (pre-initialized for the current row)- 抛出:
SQLException
- if an SQLException is encountered getting column values (that is, there's no need to catch SQLException)