Overview
Sometimes you need to call a procedure in a database. In the post, we are going to discuss how to call a procedure in a database with spring jdbc template.
Call a procedure in a database with spring jdbc template
The easiest way to call a procedure in a database is to use a spring jdbc template.
Spring jdbc template is just a wrapper around JDBC.
Firstly you have to add the following dependency to the project:
1
2
3
4
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
Then you could create a JdbcTemplate and just call a procedure like in the example below:
1
2
val jdbcTemplate = JdbcTemplate()
jdbcTemplate.execute("call procedure_example()")
Conclusion
We have discussed how to call a procedure in a database with spring jdbc template.
-
Previous
How to show SQL statements and parameters with Hibernate -
Next
How to create a scheduled method with spring boot