INOUT parameters map to an array of the parameter type in the Java programming language. (The method must take an array as its parameter.) This conforms to the recommendations of the SQL standard.
CallableStatement call = conn.prepareCall(
"{CALL doubleMyInt(?)}");
// for inout parameters, it is good practice to
// register the outparameter before setting the input value
call.registerOutParameter(1, Types.INTEGER);
call.setInt(1,10);
call.execute();
int retval = call.getInt(1);
public static void doubleMyInt(int[] i) {
i[0] *=2;
/* Derby returns the first element of the array.*/
}
The following table shows the parameter array types and return types that correspond to JDBC types.
JDBC Type | Array Type for Method Parameter | Value and Return Type |
---|---|---|
BIGINT | long[] | long |
BINARY | byte[][] | byte[] |
BLOB | java.sql.Blob[] | java.sql.Blob |
BOOLEAN | boolean[] | boolean |
CLOB | java.sql.Clob[] | java.sql.Clob |
DATE | java.sql.Date[] | java.sql.Date |
DOUBLE | double[] | double |
FLOAT | double[] | double |
INTEGER | int[] | int |
LONGVARBINARY | byte[][] | byte[] |
REAL | float[] | float |
SMALLINT | short[] | short |
TIME | java.sql.Time[] | java.sql.Time |
TIMESTAMP | java.sql.Timestamp[] | java.sql.Timestamp |
VARBINARY | byte[][] | byte[] |
OTHER | yourType[] | yourType |
JAVA_OBJECT | yourType[] | yourType |
Register the output type of the parameter before executing the call. For INOUT parameters, it is good practice to register the output parameter before setting its input value.