#jdbctemplate
Posts
-
Digging into Spring's Source 18: JdbcTemplate — the Template-Callback Pattern and Exception Translation
Plain JDBC repeats the same chores on every query — get a connection, build a Statement, handle the exception, close everything. This post follows, in the source, how JdbcTemplate gathers those chores into one place and leaves your code only a callback; how it shares a connection with @Transactional; and how a SQLException turns into a Spring exception such as DuplicateKeyException, including which translator is the default in 7.x. Written for someone seeing Spring for the first time.