October 2017
Intermediate to advanced
396 pages
10h 2m
English
Instances of the JdbcTemplate class are thread-safe once configured. As a best practice of configuring the JdbcTemplate in a Spring application, it should be constructed in the constructor injection or setter injection of the data source bean in your DAO classes by passing that data source bean as a constructor argument of the JdbcTemplate class. This leads to DAOs that look, in part, like the following:
@Repository public class JdbcAccountRepository implements AccountRepository{ JdbcTemplate jdbcTemplate; public JdbcAccountRepository(DataSource dataSource) { super(); this.jdbcTemplate = new JdbcTemplate(dataSource); } //... } Let's see some best practices to configure a database and write ...Read now
Unlock full access