Bober02
Bober02

Reputation: 15341

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

Upvotes: 4

Views: 3799

Answers (2)

ams
ams

Reputation: 62652

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

Upvotes: 1

sinuhepop
sinuhepop

Reputation: 20316

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

Upvotes: 1

Related Questions