Share this page 

Call a stored procedureTag(s): JDBC


We assume that the Connection is known as :
Connection conn;
then
String query = "begin thePackage.theProcedure(?,?,?); end;";
CallableStatement cs = conn.prepareCall(query);
cs.setString(1, "string parameter");         // #1 is INPUT
cs.setInt(2, 1);                             // #2 is INPUT 
cs.registerOutParameter(2, Types.INTEGER);   //   and OUTPUT 
cs.registerOutParameter(3, Types.INTEGER);   // #3 is OUTPUT
cs.execute();

int output_parm2 = cs.getInt(2);   // get the result from OUTPUT #2
int output_parm3 = cs.getInt(3);   // get the result from OUTPUT #3