The CallHandler<T> interface

IBM® recommends that you use the CallHandlerWithParameters<T> interface instead of the CallHandler<T> interface.

You pass CallHandler<T> objects to this version of the overloaded call() method in the Data interface:

<T> T call(java.lang.String sql,
           CallHandler<T> callHandler,
           java.lang.Object... parameters)

CallHandler<T> objects contain one method: handleCall(CallableStatement cstmt). When pureQuery calls this method, pureQuery passes an object that implements the java.sql.CallableStatement interface, which was used to run the SQL CALL statement.

Use the handleCall(CallableStatement cstmt) method to carry out the following tasks:
  • Use cstmt that pureQuery passes to access any query results that are returned by the stored procedure (using cstmt's getMoreResults(), and getResultSet() methods). See the Javadoc for your Java SDK for information about the java.sql.CallableStatement interface.
  • Use cstmt to access values returned by the OUT and INOUT parameters of a stored procedure and incorporate them into the resulting <T> object.
  • Create and return the object of type <T> that the inline method returns. The object can contain, for example, the contents of any query results that were returned. However, there are no restrictions on the information that the object can contain.

You can use this interface only with inline methods.

Example

In this example, the code creates a new CallHandler<T> object called GetAddEmResult_CallHandler.

MyBean spResults = db.call("{?1 = Call ADDEM (?2, ?3, ?4)}",
		new custom.GetAddEmResult_CallHandler(), int outVal, int inVal1, int inVal2, int inVal3)

Feedback