Spring JDBC Framework simplifies the use of JDBC and helps to avoid common errors.
The following example shows querying records using NamedParameterJdbcTemplate class.
It extracts the specified named parameters from the given map for query execution.
/**
* Initialize context and get the NamedParameterJdbcTemplate
*/
ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");
DataSource dataSource = (DataSource) appContext.getBean("dataSource");
NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(dataSource);