What is a stored procedure? How to call stored procedure using JDBC API | Eklavya Online

What is a stored procedure? How to call stored procedure using JDBC API

Stored procedure is a group of SQL statements that forms a logical unit and performs a particular task. Stored Procedures are used to encapsulate a set of operations or queries to execute on database. Stored procedures can be compiled and executed with different parameters and results and may have any combination of input/output parameters. Stored procedures can be called using CallableStatement class in JDBC API. Below code snippet shows how this can be achieved.

  • CallableStatement cs = con.prepareCall(“{call MY_STORED_PROC_NAME}”);
  • ResultSet rs = cs.executeQuery();