|
Answer» This can be done by using the QUERY method of JdbcTemplate. There are two interfaces that help to do this: - ResultSetExtractor:
- It defines only ONE method extractData that ACCEPTS ResultSet instance as a parameter and returns the list.
- Syntax:
public T extractData(ResultSet RS) throws SQLException,DataAccessException;- RowMapper:
- This is an enhanced version of ResultSetExtractor that saves a lot of CODE.
- It allows to map a row of the relations with the instance of the user-defined class.
- It iterates the ResultSet internally and adds it into the result collection thereby saving a lot of code to fetch records.
|