Showing posts with label DataSource. Show all posts
Showing posts with label DataSource. Show all posts

Friday, 18 July 2014

Spring JDBC connection with jdbcTemplate and JdbcDaoSupport


Hello! Today I want to make a couple of examples of database access using JDBC within Spring framework. In this article we'll see how DB's manipulations can be  simplified using jdbcTemplate and JdbcDaoSupport.

Cute image from me:
If we don't use jdbcTemplate we must again and again, in every method, repeat yourself writing duplicate code for opening and clothing connection to DB, etc.

Why? I really don't understand, this solution is opposite to the one of OOP design principle (DRY: Don't Repeat Yourself). If you use some code more then ones - then you must detach it to a separate method and invoke it every time you need in the future.

Spring developers offer us to avoid repeating yourself and use jdbcTemplate which can do all redundant work for us.

Let's see the differences!