Spring JDBC Framework simplifies the use of JDBC and helps to avoid common errors.
The following example shows querying for typed list using JdbcTemplate class.
/**
* Initialize context and get the JdbcTemplate
*/
ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");
DataSource dataSource = (DataSource) appContext.getBean("dataSource");
JdbcTemplate template = new JdbcTemplate(dataSource);
//The results will be mapped to a List (one entry for each row)
//of result objects, each of them matching the specified element type.
List<String> statusList =
template.queryForList("select distinct(STATUS) from BUG_STAT", String.class);
System.out.println(statusList);
List<Integer> statusIDList =
template.queryForList("select ID from BUG_STAT", Integer.class);