Table of Contents

About

The CallableStatement objects interface adds methods to the statement interface for retrieving output parameter values returned from stored procedures.

See CallableStatement objects

Syntax

CallableStatement objects may take three types of parameters: IN, OUT, and INOUT.

CallableStatement object for calling the stored procedure ‘validate’, which has a return parameter and two other parameters.

Example

CallableStatement cstmt = conn.prepareCall(
“{? = call validate(?, ?)}”);

CallableStatement cstmt = con.prepareCall(
"{CALL PROC(?, "Literal_Value", ?)}");
cstmt.setString(1, "First");
cstmt.setString(2, "Third");

// out parameter
cstmt.registerOutParameter(1, java.sql.Types.STRING);
cstmt.registerOutParameter(2, java.sql.Types.FLOAT);
cstmt.execute();
// Retrieve OUT parameters
String name = cstmt.getString(1);
float number = cstmt.getFloat(2);

// the two parameter markers have the ordinal values 1 and 2.
cstmt.setFloat("PARAM_5", 150.25);