Spring JDBC Framework simplifies the use of JDBC and helps to avoid common errors.
The following example shows deleting an existing record 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);
int userId = 6;
template.update("delete from USER where ID = ? ", userId);
System.out.println("Successfully deleted user");
}