Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RowCallbackHandler#processRow methoud should not call next() on the ResultSet #4

Open
Hubbitus opened this issue Jun 11, 2020 · 0 comments

Comments

@Hubbitus
Copy link

https://mkyong.com/spring/spring-jdbctemplate-handle-large-resultset/ provides example code:

import org.springframework.jdbc.core.RowCallbackHandler;

	jdbcTemplate.query("select * from books", new RowCallbackHandler() {
		public void processRow(ResultSet resultSet) throws SQLException {
			while (resultSet.next()) {
				String name = resultSet.getString("Name");
				// process it
			}
		}
	});

and calls resultSet.next() in while loop. But documentation about RowCallbackHandler#processRow clearly stated what it should not be done. Citing:

Implementations must implement this method to process each row of data in the ResultSet. This method should not call next() on the ResultSet; it is only supposed to extract values of the current row.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant