com.ibm.as400.access
Class AS400JDBCCallableStatement

java.lang.Object
  |
  +--com.ibm.as400.access.AS400JDBCStatement
        |
        +--com.ibm.as400.access.AS400JDBCPreparedStatement
              |
              +--com.ibm.as400.access.AS400JDBCCallableStatement

public class AS400JDBCCallableStatement
extends AS400JDBCPreparedStatement
implements java.sql.CallableStatement

The AS400JDBCCallableStatement class runs a stored procedure. Use Connection.prepareCall() to create new CallableStatement objects.

Parameters are indexed sequentially, by number, starting at 1. The caller must register output parameters before executing the stored procedure.


Method Summary
 java.sql.Array getArray(int parameterIndex)
          Returns the value of an SQL ARRAY output parameter as an Array value.
 java.math.BigDecimal getBigDecimal(int parameterIndex)
          Returns the value of an SQL NUMERIC or DECIMAL output parameter as a BigDecimal object.
 java.math.BigDecimal getBigDecimal(int parameterIndex, int scale)
          Deprecated. Use getBigDecimal(int) instead.
 java.sql.Blob getBlob(int parameterIndex)
          Returns the value of an SQL BLOB output parameter as a Blob value.
 boolean getBoolean(int parameterIndex)
          Returns the value of an SQL SMALLINT output parameter as a Java boolean.
 byte getByte(int parameterIndex)
          Returns the value of an SQL SMALLINT output parameter as a Java byte.
 byte[] getBytes(int parameterIndex)
          Returns the value of an SQL BINARY or VARBINARY output parameter as a Java byte array.
 java.sql.Clob getClob(int parameterIndex)
          Returns the value of an SQL CLOB output parameter as a Clob value.
 java.sql.Date getDate(int parameterIndex)
          Returns the value of an SQL DATE output parameter as a java.sql.Date object using the default calendar.
 java.sql.Date getDate(int parameterIndex, java.util.Calendar calendar)
          Returns the value of an SQL DATE output parameter as a java.sql.Date object using a calendar other than the default.
 double getDouble(int parameterIndex)
          Returns the value of an SQL DOUBLE or FLOAT output parameter as a Java double.
 float getFloat(int parameterIndex)
          Returns the value of an SQL REAL or FLOAT output parameter as a Java float.
 int getInt(int parameterIndex)
          Returns the value of an SQL INTEGER output parameter as a Java int.
 long getLong(int parameterIndex)
          If the connected AS/400 supports SQL BIGINT data, this returns the value of an SQL BIGINT output parameter as a Java long.
 java.lang.Object getObject(int parameterIndex)
          Returns the value of an output parameter as a Java Object.
 java.lang.Object getObject(int parameterIndex, java.util.Map typeMap)
          Returns the value of an output parameter as a Java Object.
 java.sql.Ref getRef(int parameterIndex)
          Returns the value of an SQL REF output parameter as a Ref value.
 short getShort(int parameterIndex)
          Returns the value of an SQL SMALLINT output parameter as a Java short value.
 java.lang.String getString(int parameterIndex)
          Returns the value of an SQL CHAR or VARCHAR output parameter as a Java String object.
 java.sql.Time getTime(int parameterIndex)
          Returns the value of an SQL TIME output parameter as a java.sql.Time object using the default calendar.
 java.sql.Time getTime(int parameterIndex, java.util.Calendar calendar)
          Returns the value of an SQL TIME output parameter as a java.sql.Time object using a calendar other than the default.
 java.sql.Timestamp getTimestamp(int parameterIndex)
          Returns the value of an SQL TIMESTAMP output parameter as a java.sql.Timestamp object using the default calendar.
 java.sql.Timestamp getTimestamp(int parameterIndex, java.util.Calendar calendar)
          Returns the value of an SQL TIMESTAMP output parameter as a java.sql.Timestamp object using a calendar other than the default.
 void registerOutParameter(int parameterIndex, int sqlType)
          Registers the type for an output parameter.
 void registerOutParameter(int parameterIndex, int sqlType, int scale)
          Registers the type for an output parameter.
 void registerOutParameter(int parameterIndex, int sqlType, java.lang.String typeName)
          Registers the type for an output parameter.
 boolean wasNull()
          Indicates if the last parameter read has the value of SQL NULL.
 
Methods inherited from class com.ibm.as400.access.AS400JDBCPreparedStatement
addBatch, addBatch, clearParameters, close, execute, execute, executeBatch, executeQuery, executeQuery, executeUpdate, executeUpdate, getMetaData, setArray, setAsciiStream, setBigDecimal, setBinaryStream, setBlob, setBoolean, setByte, setBytes, setCharacterStream, setClob, setDate, setDate, setDouble, setFloat, setInt, setLong, setNull, setNull, setObject, setObject, setObject, setRef, setShort, setString, setTime, setTime, setTimestamp, setTimestamp, setUnicodeStream
 
Methods inherited from class com.ibm.as400.access.AS400JDBCStatement
cancel, clearBatch, clearWarnings, finalize, getConnection, getFetchDirection, getFetchSize, getMaxFieldSize, getMaxRows, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetType, getUpdateCount, getWarnings, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getArray

public java.sql.Array getArray(int parameterIndex)
                        throws java.sql.SQLException
Returns the value of an SQL ARRAY output parameter as an Array value. DB2 for OS/400 does not support arrays.
Specified by:
getArray in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or 0 if the value is SQL NULL.
Throws:
java.sql.SQLException - Always thrown because DB2 for OS/400 does not support arrays.

getBigDecimal

public java.math.BigDecimal getBigDecimal(int parameterIndex)
                                   throws java.sql.SQLException
Returns the value of an SQL NUMERIC or DECIMAL output parameter as a BigDecimal object.
Specified by:
getBigDecimal in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or null if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getBigDecimal

public java.math.BigDecimal getBigDecimal(int parameterIndex,
                                          int scale)
                                   throws java.sql.SQLException
Deprecated. Use getBigDecimal(int) instead.

Returns the value of an SQL NUMERIC or DECIMAL output parameter as a BigDecimal object.
Specified by:
getBigDecimal in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
scale - The number of digits after the decimal.
Returns:
The parameter value or null if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the scale is not valid, the statement was not executed, or the requested conversion is not valid.
See Also:
getBigDecimal(int)

getBlob

public java.sql.Blob getBlob(int parameterIndex)
                      throws java.sql.SQLException
Returns the value of an SQL BLOB output parameter as a Blob value.
Specified by:
getBlob in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or 0 if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getBoolean

public boolean getBoolean(int parameterIndex)
                   throws java.sql.SQLException
Returns the value of an SQL SMALLINT output parameter as a Java boolean.
Specified by:
getBoolean in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or false if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getByte

public byte getByte(int parameterIndex)
             throws java.sql.SQLException
Returns the value of an SQL SMALLINT output parameter as a Java byte.
Specified by:
getByte in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or 0 if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid, or an error occurs.

getBytes

public byte[] getBytes(int parameterIndex)
                throws java.sql.SQLException
Returns the value of an SQL BINARY or VARBINARY output parameter as a Java byte array.
Specified by:
getBytes in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or null if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getClob

public java.sql.Clob getClob(int parameterIndex)
                      throws java.sql.SQLException
Returns the value of an SQL CLOB output parameter as a Clob value.
Specified by:
getClob in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or 0 if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getDate

public java.sql.Date getDate(int parameterIndex)
                      throws java.sql.SQLException
Returns the value of an SQL DATE output parameter as a java.sql.Date object using the default calendar.
Specified by:
getDate in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or null if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getDate

public java.sql.Date getDate(int parameterIndex,
                             java.util.Calendar calendar)
                      throws java.sql.SQLException
Returns the value of an SQL DATE output parameter as a java.sql.Date object using a calendar other than the default.
Specified by:
getDate in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
calendar - The calendar.
Returns:
The parameter value or null if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, the calendar is null, or the requested conversion is not valid.

getDouble

public double getDouble(int parameterIndex)
                 throws java.sql.SQLException
Returns the value of an SQL DOUBLE or FLOAT output parameter as a Java double.
Specified by:
getDouble in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or 0 if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getFloat

public float getFloat(int parameterIndex)
               throws java.sql.SQLException
Returns the value of an SQL REAL or FLOAT output parameter as a Java float.
Specified by:
getFloat in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or 0 if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getInt

public int getInt(int parameterIndex)
           throws java.sql.SQLException
Returns the value of an SQL INTEGER output parameter as a Java int.
Specified by:
getInt in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or 0 if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getLong

public long getLong(int parameterIndex)
             throws java.sql.SQLException
If the connected AS/400 supports SQL BIGINT data, this returns the value of an SQL BIGINT output parameter as a Java long. Otherwise, this returns the value of an SQL INTEGER output parameter as a Java long. SQL BIGINT data is supported on V4R5 and later.
Specified by:
getLong in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or 0 if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getObject

public java.lang.Object getObject(int parameterIndex)
                           throws java.sql.SQLException
Returns the value of an output parameter as a Java Object. The type of the object corresponds to the SQL type that was registered for this parameter using registerOutParameter(). When the parameter is a user-defined type, then the connection's type map is used to create the object.
Specified by:
getObject in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or null if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getObject

public java.lang.Object getObject(int parameterIndex,
                                  java.util.Map typeMap)
                           throws java.sql.SQLException
Returns the value of an output parameter as a Java Object. This driver does not support the type map.
Specified by:
getObject in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
type - The type map. This is not used.
Returns:
The parameter value or null if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getRef

public java.sql.Ref getRef(int parameterIndex)
                    throws java.sql.SQLException
Returns the value of an SQL REF output parameter as a Ref value. DB2 for OS/400 does not support structured types.
Specified by:
getRef in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or 0 if the value is SQL NULL.
Throws:
java.sql.SQLException - Always thrown because DB2 for OS/400 does not support REFs.

getShort

public short getShort(int parameterIndex)
               throws java.sql.SQLException
Returns the value of an SQL SMALLINT output parameter as a Java short value.
Specified by:
getShort in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or 0 if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getString

public java.lang.String getString(int parameterIndex)
                           throws java.sql.SQLException
Returns the value of an SQL CHAR or VARCHAR output parameter as a Java String object.
Specified by:
getString in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or null if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getTime

public java.sql.Time getTime(int parameterIndex)
                      throws java.sql.SQLException
Returns the value of an SQL TIME output parameter as a java.sql.Time object using the default calendar.
Specified by:
getTime in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or null if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getTime

public java.sql.Time getTime(int parameterIndex,
                             java.util.Calendar calendar)
                      throws java.sql.SQLException
Returns the value of an SQL TIME output parameter as a java.sql.Time object using a calendar other than the default.
Specified by:
getTime in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
calendar - The calendar.
Returns:
The parameter value or null if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, the calendar is null, or the requested conversion is not valid.

getTimestamp

public java.sql.Timestamp getTimestamp(int parameterIndex)
                                throws java.sql.SQLException
Returns the value of an SQL TIMESTAMP output parameter as a java.sql.Timestamp object using the default calendar.
Specified by:
getTimestamp in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
Returns:
The parameter value or null if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, or the requested conversion is not valid.

getTimestamp

public java.sql.Timestamp getTimestamp(int parameterIndex,
                                       java.util.Calendar calendar)
                                throws java.sql.SQLException
Returns the value of an SQL TIMESTAMP output parameter as a java.sql.Timestamp object using a calendar other than the default.
Specified by:
getTimestamp in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
calendar - The calendar.
Returns:
The parameter value or null if the value is SQL NULL.
Throws:
java.sql.SQLException - If the statement is not open, the index is not valid, the index is not registered as an output parameter, the statement was not executed, the calendar is null, or the requested conversion is not valid.

registerOutParameter

public void registerOutParameter(int parameterIndex,
                                 int sqlType,
                                 int scale)
                          throws java.sql.SQLException
Registers the type for an output parameter. Before executing the stored procedure call, explicitly register the type of each output parameter. When reading the value of an output parameter, use a get method that corresponds to the registered type. A parameter that is used for both input and output can not be registered with a different type than was used when it was set.
Specified by:
registerOutParameter in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
sqlType - The SQL type code defined in java.sql.Types.
scale - The number of digits after the decimal if sqlType is DECIMAL or NUMERIC.
Throws:
java.sql.SQLException - If the index is not valid, the scale is not valid, the parameter is not an output parameter, or the requested conversion is not valid.

registerOutParameter

public void registerOutParameter(int parameterIndex,
                                 int sqlType)
                          throws java.sql.SQLException
Registers the type for an output parameter. Before executing the stored procedure call, explicitly register the type of each output parameter. When reading the value of an output parameter, use a get method that corresponds to the registered type. A parameter that is used for both input and output can not be registered with a different type than was used when it was set.
Specified by:
registerOutParameter in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
sqlType - The SQL type code defined in java.sql.Types.
Throws:
java.sql.SQLException - If the index is not valid, the parameter is not an output parameter, or the requested conversion is not valid.

registerOutParameter

public void registerOutParameter(int parameterIndex,
                                 int sqlType,
                                 java.lang.String typeName)
                          throws java.sql.SQLException
Registers the type for an output parameter. Before executing the stored procedure call, explicitly register the type of each output parameter. When reading the value of an output parameter, use a get method that corresponds to the registered type. A parameter that is used for both input and output can not be registered with a different type than was used when it was set.
Specified by:
registerOutParameter in interface java.sql.CallableStatement
Parameters:
parameterIndex - The parameter index (1-based).
sqlType - The SQL type code defined in java.sql.Types.
typeName - The fully-qualified name of an SQL structured type. This value will be ignored.
Throws:
java.sql.SQLException - If the index is not valid, the parameter is not an output parameter, or the requested conversion is not valid.

wasNull

public boolean wasNull()
                throws java.sql.SQLException
Indicates if the last parameter read has the value of SQL NULL.
Specified by:
wasNull in interface java.sql.CallableStatement
Returns:
true if the value is SQL NULL; false otherwise.
Throws:
java.sql.SQLException - If the statement is not open.