Chapter 5
Section 5.2
Using JDBC/ODBC Operations
JDBC eWay Database Operations (JCD)
JDBC/ODBC eWay Adapter User’s Guide
65
Sun Microsytems, Inc.
FileClient_1.write();
}
}
Manipulating the ResultSet and Update Count Returned by Stored
Procedure
For Stored Procedures that return ResultSets and Update Count, the following methods
are provided to manipulate the ResultSet:
enableResultSetOnly
enableUpdateCountsOnly
enableResultSetandUpdateCounts
resultsAvailable
next
getUpdateCount
available
Many drivers do not support manipulating ResultSets in a Stored Procedure. It is
recommended that you use specific eWay Adapters for Oracle, SQL Server, Sybase,
DB2, and so forth, to peform such operations.
JDBC stored procedures do not return records as ResultSets. Instead, the records are
returned through output reference cursor parameters. Reference Cursor parameters are
essentially ResultSets.
The
resultsAvailable()
method, added to the PreparedStatementAgent class, simplifies
the whole process of determining whether any results, be it Update Counts or
ResultSets, are available after a stored procedure has been executed. Although JDBC
provides three methods (
getMoreResults()
,
getUpdateCount()
, and
getResultSet()
) to
access the results of a stored procedure call, the information returned from these
methods can be quite confusing to the inexperienced Java JDBC programmer and they
also differ between vendors. You can simply call
resultsAvailable()
and if Boolean true
is returned, you can expect either a valid Update Count when
getUpdateCount()
is
called and/or the next ResultSet has been retrieved and made available to one of the
ResultSet nodes defined for the Stored Procedure OTD, when that node’s
available()
method returns true.
Frequently, Update Counts information that is returned from a Stored Procedures is
insignificant. You should process returned ResultSet information and avoid looping
through all of the Update Counts. The following three methods control exactly what
information should be returned from a stored procedure call. The
enableResultSetsOnly()
method, added to the PreparedStatement Agent class allows
only ResultSets to be returned and thus every
resultsAvailable()
called only returns
Boolean true if a ResultSet is available. Likewise, the
enableUpdateCountsOnly()
causes
resultsAvailable()
to return true only if an Update Count is available. The
default case of
enableResultsetsAndUpdateCount()
method allows both ResultSets
and Update Counts to be returned.