Spring is a popular Java web framework for developing Enterprise web applications. Spring boot is a tool to create Spring based applications quickly and easily.

Spring provides support for JDBC to communicate with database. It provides a class JdbcTemplate, which internally uses JDBC API but it minimises all the boiler plate code.

Overview


Spring JdbcTemplate is a powerful mechanism to connect to the database and execute SQL queries. It internally uses JDBC api, but eliminates a lot of problems of JDBC API.

It is the central class in the Spring JDBC support classes. It takes care of creation and release of resources such as creating and closing of connection object etc. So it will not lead to any problem if you forget to close the connection.

It handles the exception and provides the informative exception messages by the help of exception classes defined in the org.springframework.dao package.

We can perform all the database operations by the help of JdbcTemplate class such as insertion, updation, deletion and retrieval of the data from the database.

Advantages of using JdbcTemplate


  • Creation and closing of connections
  • Running statements and stored procedure calls
  • Iterating over the ResultSet and returning results
  • Provides support of exception handling

Reference courses


Following are the reference courses, to learn more about Spring and Spring JDBC

1) Spring Framework Master Class – Java Spring the Modern Way


2) Spring Boot Fundamentals


Reference Books


Following are the reference books, to learn more about Spring and Spring Boot

Watch the video


Examples


Following are the Spring JDBC examples, follow these tutorials in the order which is mentioned