The following code below wraps Spring's JdbcTemplate, which is a very useful library that let's you use JDBC without the overhead of handling the creation and disposal of JDBC connection, Statement and ResultSet.
There are some reasons of using this class instead of using Jdbctemplate directly:
1) The code is very simple to use (only one class).
2) It's a singleton that keeps a cache of javax.sql.DataSource instances.
3) It allows to perform SQL operations (insert, update and query) on many databases without creating a new DataSource each time.
4) The singleton exposes only the most useful API of the JdbcTemplate class.
5) It enforces the usage of Generics when querying for Objects.
In order to make this class to run, you need to add the following jar files to your classpath:
org.springframework.core-3.0.0.M3.jar