As we discussed in our earlier tutorial about Spring Framework Introduction, for spring setup in your local machine we need the following prerequisites
- Java (need 1.6 or above for Spring 4.0)
- Java supported IDE like Eclipse, Netbeans etc
- Spring Release Library files.
- Web Server (for Spring Web Module)
What is Spring IOC ?
Spring IOC (Inversion Of Control) also known as Dependency Injection is basically the core part of Spring framework which is responsible for managing object lifecycles of specific objects: creating these objects, calling their initialization methods, and configuring these objects by wiring them together. Object created by the Spring Container are known as Bean. Spring IOC and Dependency injection is based on Factory Design Pattern.
What is AOP ?
Aspect Oriented Programming(AOP) is just not a feature that Spring provide, It is a model of programming that built over substitute of OOP which entails breaking down program logic into distinct parts (so-called concerns). It does not replace or remove OOP, but it add a much more flexibility over that.
Spring JdbcTemplate is a powerful mechanism to connect to the database and execute SQL queries. It internally uses JDBC api, but eliminates a lot of problems of JDBC API.
Problems with JDBC API
We all are aware of the JDBC(Java Database Connection) to connect the Java application to database for various DML and DDL operation and storing the data in database.
- For doing a CRUD(Create Retrieve Update Delete) operation in simple JDBC we have to write a lot of code as well as have to think and handle each and every exception scenario.
- We need to perform exception handling code on the database logic.
- We need to handle transaction.
- Repetition of all these codes from one to another database logic is a time consuming task.
Below is the basic code for a select query via JDBC.