4.3.1 Using Named Notation with a CallableStatement Object

Table of Contents Previous Next



The JDBC Connector (Advanced Server version 9.6 and later) supports the use of named parameters when instantiating a CallableStatement object. This syntax is an extension of JDBC supported syntax, and does not conform to the JDBC standard.
You can use a CallableStatement object to pass parameter values to a stored procedure. You can assign values to IN, OUT, and INOUT parameters with a CallableStatement object.
When using the CallableStatement class, you can use ordinal notation or named notation to specify values for an actual arguments. You must set a value for each IN or INOUT parameter marker in a statement.
When using ordinal notation to pass values to a CallableStatement object, you should use the setter method that corresponds to the parameter type. For example, when passing a STRING value, use the setString setter method. Each parameter marker within a statement (?) represents an ordinal value. When using ordinal parameters, you should pass the actual parameter values to the statement in the order that the formal arguments are specified within the procedure definition.
You can also use named parameter notation when specifying argument values for a CallableStatement object. Named parameter notation allows you to supply values for only those parameters that are required by the procedure, omitting any parameters that have acceptable default values. You can also specify named parameters in any order.
When using named notation, each parameter name should correspond to a COLUMN_NAME returned by a call to the DatabaseMetaData getProcedureColumns method. You should use the => token when including a named parameter in a statement call.
Use the registerOutParameter method to identify each OUT or INOUT parameter marker in the statement.
The following examples demonstrate using the CallableStatement method to provide parameters to a procedure with the following signature:


Table of Contents Previous Next