Using ResultSetExcractor in Spring JdbcTemplate
- Thursday, October 27, 2011, 8:41
- Spring Framework, Spring JDBC
- Add a comment
JdbcTemplate class includes query methods to prepare and execute the SQL queries. The Spring JDBC abstraction framewor provides three different types of callbacks to read the results after executing the SQL query using query() methods.
- ResultSetExtractor
- RowCallbackHandler
- RowMapper
Let’s start our discussion with ResultSetExtractor.
ResultSetExtractor contains only one method with the regnature shown in the following code snippet.
The implementation class of this interface need to implements the extractData() metod, which takes the responsibility of extracting results from a ResultSet, but it does not need to worry about handling SQLException raised while extracting the results.
The SQLException will be caught and handle by JdbcTemplate class calling this implementation.

