[英]JDBC/Spring - execute sql query to get iterator of results
So far I have been using 'SimpleJdbcTemplate' and used a 'RowCallbackHadler' to process the whole result of the query. 到目前为止,我一直在使用'SimpleJdbcTemplate'并使用'RowCallbackHadler'处理查询的整个结果。 At the moment I would like to receive an iterator-like object, which I could query for the next table row whe interested. 目前,我希望收到一个类似迭代器的对象,可以查询感兴趣的下一个表行。 Is the following behaviour possible in Spring/jdbc (preferrably slpring)? 在Spring / jdbc中是否可能发生以下行为(最好是slpring)?
You can use a ResultSetExtractor instead of a RowCallbackHadler
. 您可以使用ResultSetExtractor代替RowCallbackHadler
。 Methods in JdbcTemplate
accepting the latter will accept the former too. JdbcTemplate
接受后者的方法也将接受前者。
You can try using the JdbcTemplate method queryforRowSet 您可以尝试使用JdbcTemplate方法queryforRowSet
public SqlRowSet queryForRowSet(String sql,
Object... args)
throws DataAccessException
http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/jdbc/core/JdbcTemplate.html#queryForRowSet%28java.lang.String,%20java.lang.Object...%29 http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/jdbc/core/JdbcTemplate.html#queryForRowSet%28java.lang.String,%20java.lang.Object...% 29
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.