Skip to content

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

@Hubbitus

Description

@Hubbitus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions