public interface ResultSetExtractor<T>
JdbcTemplate的查询方法使用的回调接口。 这个接口的实现执行从java.sql中提取结果的实际工作。 结果集,但不需要担心异常处理。SQLExceptions将被调用JdbcTemplate捕获和处理。
这个接口主要在JDBC框架内部使用。 RowMapper通常是ResultSet处理的更简单的选择,每行映射一个结果对象,而不是整个ResultSet的一个结果对象。
注意:与RowCallbackHandler不同的是,ResultSetExtractor对象通常是无状态的,因此是可重用的, 只要它不访问有状态资源(例如流化LOB内容时的输出流)或在对象中保持结果状态。
| 限定符和类型 | 方法和说明 |
|---|---|
T |
extractData(ResultSet rs)
Implementations must implement this method to process the entire ResultSet.
|
T extractData(ResultSet rs) throws SQLException, DataAccessException
rs - ResultSet to extract data from. Implementations should not close
this: it will be closed by the calling JdbcTemplate.null if none (the extractor
will typically be stateful in the latter case).SQLException - if a SQLException is encountered getting column
values or navigating (that is, there's no need to
catch SQLException)DataAccessException - in case of custom exceptionsCopyright © 2023. All rights reserved.