October 2018
Intermediate to advanced
556 pages
15h 18m
English
To simplify the hassle surrounding raw JDBC, Spring provides the Spring JDBC module, which is pretty old but well described. This module offers a few versions of the JdbcTemplate class that helps to execute queries and maps relational rows into entities. It also handles the creation and release of resources, helping to omit common errors such as forgetting to close a prepared statement or connection. JdbcTemplate also catches JDBC exceptions and translates them to generic org.springframework.dao exceptions.
Let's say we have a collection of books in an SQL database and the entity is represented by the following Java class:
class Book { private int id; private String title; public Book() { } public Book(int id, String title)