SQL/MX Guide to Stored Procedures in Java (G06.24+, H06.03+)

Invoking SPJs in NonStop SQL/MX
HP NonStop SQL/MX Guide to Stored Procedures in Java523727-004
5-14
Invoking SPJs in a JDBC/MX Program
Invoking SPJs in a JDBC/MX Program
You can execute a CALL statement in a JDBC/MX program by using the JDBC
CallableStatement interface. JDBC/MX requires that you put the CALL statement
in an escape clause:
Set input values for IN and INOUT parameters by using the settype() methods of
the CallableStatement interface.
Retrieve output values from OUT and INOUT parameters by using the gettype()
methods of the CallableStatement interface.
If the parameter mode is OUT or INOUT, you must register the parameter as an output
parameter by using the registerOutParameter() method of the
CallableStatement interface before executing the CALL statement.
In this example, a CALL statement is executed from a JDBC/MX program:
CallableStatement stmt =
con.prepareCall("{call adjustsalary(?,?,?)}");
stmt.setBigDecimal(1,202); // x = 202
stmt.setDouble(2,5.5); // y = 5.5
stmt.registerOutParameter(3, java.sql.Types.NUMERIC);
stmt.execute();
int z = stmt.getBigDecimal(3); // Retrieve the value of the
// OUT parameter
For more information about JDBC/MX and mappings of SQL/MX to JDBC data types,
see the JDBC Driver for SQL/MX Programmers Reference.
{call procedure-name ([parameter[{, parameter}...]])}