Stored Procedures and Functions
This tutorial will discuss Stored Procedures and Functions in the spring framework using Spring DAO/JDBC. If we want to access stored procedures and functions available in the database from the Spring JDBC application, we have to use “SimpleJdbcCall.” To use SimpleJdbcCall in Spring Jdbc applications, we have to use the following steps.
1. Create the DAO interface and its implementation class.
2. In DAO implementation class, we have to declare DataSource and JdbcTemplate and their respective setter method.
3. Inside the setter method, we have to create a SimpleJdbcCall object.
SimpleJdbcCall jdbcCall = new SimpleJdbcCall(); jdbcCall.withProcedureName("proc_Name");
4. Configure DataSource and DAO implementation class in the beans configuration file.
5. Access the “execute” method by passing IN type parameters values in the form of “SQLParameterSource.”
public Map execute(Map m) public Map execute(SqlParameterSource paramSource) public Map execute(Object ... obj)