Working with JdbcTemplate

As you learned earlier, Spring's JdbcTemplate solves two main problems in the application. It solves the redundant code problem as well as poor exception handling of the data access code in the application. Without JdbcTemplate in your application, only 20% of the code is required for querying a row, but 80% is boilerplate which handles exceptions and manages resources. If you use JdbcTemplate, then there is no need to worry about the 80% boilerplate code. Spring's JdbcTemplate, in a nutshell, is responsible for the following:

  • Acquisition of the connection
  • Participation in the transaction
  • Execution of the statement
  • Processing of the result set
  • Handling any exceptions
  • Release of the connection

Let's see when to use JdbcTemplate in the application, and how to create it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset