0 votes
in Spring by
How can you fetch records by Spring JdbcTemplate?

1 Answer

0 votes
by

This can be done by using the query method of JdbcTemplate. There are two interfaces that helps 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 a enhanced version of ResultSetExtractor that saves a lot of code.

It allows to map a row of the relations with the instance of user-defined class.

It iterates the ResultSet internally and adds it into the result collection thereby saving lot of code to fetch records.

Related questions

0 votes
asked Apr 4, 2021 in Spring by Robindeniel
0 votes
asked Apr 4, 2021 in Spring by Robindeniel
...