简体   繁体   中英

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. 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)?

You can use a ResultSetExtractor instead of a RowCallbackHadler . Methods in JdbcTemplate accepting the latter will accept the former too.

You can try using the JdbcTemplate method 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM