CallableStatement example with IN OUT parameters

CallableStatement in JDBC is used to execute Stored Procedures.

A Stored Procedure can have 3 types of parameters
1. IN – is input parameter to the procedure
2. OUT – is output parameter returning from procedure
3. INOUT – acts as both input and output parameter.

Create a Stored Procedure in Database

Steps to Call a Stored Procedure using CallableStatement

1. Create a CallableStatement Object
Syntax to call the store procedure is
{call (IN-OUT params)}

2. Set IN param values

3. Register the OUT params

Based on the output param type we need to set the appropriate java.sql.Types

4. Execute the CallableStatement

5. get the output from the CallableStatement

Full Example : CallableStatement example with IN OUT