Using RowCallbackHandler in Spring JdbcTemplate
- Thursday, October 27, 2011, 8:47
- Spring Framework, Spring JDBC
- Add a comment
CallbackHandler is a interface used by JdbcTemplate’s query methods. This interface cantains only one method with the signature in the following code snippet.
The implementation class of this interface needs to implements the processRow() method, which take responsibility to process each row of data in the ResultSet. The processRow() method should not call next() on the ResultSet. It requiredd to extract values of the current row and process the data on per-row basis.
Usually the processRow() method does not need to worry about handling the SQLException, the SQLException will be caught and handle by JdbcTemplate class calling this implementation.
Following code shows ProductResult class implementing RowCallbackHandler interface..

