devxlogo

Using a JDBC Template

Using a JDBC Template

Spring provides a nice abstraction on top of the JDBC API using JdbcTemplate and also provides great transaction management capabilities using annotation-based approach. By using the JdbcTemplate and NamedParameterjdbcTemplate classes, we can take advantage of auto configuration features and eliminate the need to configure beans by ourselves, as you can see below:

@Componentpublic class MyFoo{   private final JdbcTemplate jdbcTemplate;   @Autowired   public MyFoo(JdbcTemplate jdbcTemplate){            this.jdbcTemplate = jdbcTemplate;   }    //..}

devx-admin

Share the Post: