Spring JdbcTemplate Querying Example

Querying for Multiple Rows
Now, query or extract multiple rows from database, and convert it into a List.

Map it manually
In mutiple return rows, RowMapper is not supported in queryForList() method, you need to map it manually.

public List<Customer> findAll(){
	String sql = "SELECT * FROM CUSTOMER";
	List<Customer> customers = new ArrayList<Customer>();
	List<Map> rows = getJdbcTemplate().queryForList(sql);
	for (Map row : rows) {
		Customer customer = new Customer();
	return customers;

For more examples;
Source: http://www.mkyong.com/spring/spring-jdbctemplate-querying-examples/


About kaanmutlu

Software Developer - Computer Engineer from Istanbul, Turkey
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s