Chapter 5

Section 5.2

Using JDBC/ODBC Operations

JDBC eWay Database Operations (JCD)

Collaboration usability for a stored procedure ResultSet

The Column data of the ResultSets can be dragged-and-dropped from their nodes to the Business Rules. Below is a code snippet that can be generated by the Collaboration Editor:

while (getSPIn().getSpS_multi().resultsAvailable())

{

if (getSPIn().getSpS_multi().getUpdateCount() > 0)

{

System.err.println("Updated "+getSPIn().getSpS_multi().getUpdateCount()+" rows");

}

if (getSPIn().getSpS_multi().getNormRS().available())

{

while (getSPIn().getSpS_multi().getNormRS().next())

{

System.err.println("Customer Id = "+getSPIn().getSpS_multi().getNormRS().getCustomerId());

System.err.println("Customer Name = "+getSPIn().getSpS_multi().getNormRS().getCustomerName());

System.err.println();

}

System.err.println("===");

}

else if (getSPIn().getSpS_multi().getDbEmployee().available())

{

while (getSPIn().getSpS_multi().getDbEmployee().next())

{

System.err.println("EMPNO = "+getSPIn().getSpS_multi().getDbEmployee().getEMPNO());

System.err.println("ENAME = "+getSPIn().getSpS_multi().getDbEmployee().getENAME());

System.err.println("JOB = "+getSPIn().getSpS_multi().getDbEmployee().getJOB());

System.err.println("MGR = "+getSPIn().getSpS_multi().getDbEmployee().getMGR());

System.err.println("HIREDATE = "+getSPIn().getSpS_multi().getDbEmployee().getHIREDATE());

System.err.println("SAL = "+getSPIn().getSpS_multi().getDbEmployee().getSAL());

System.err.println("COMM = "+getSPIn().getSpS_multi().getDbEmployee().getCOMM());

System.err.println("DEPTNO = "+getSPIn().getSpS_multi().getDbEmployee().getDEPTNO());

System.err.println();

}

System.err.println("===");

}

}

Note: resultsAvailable() and available() cannot be indiscriminately called because each time they move ResultSet pointers to the appropriate locations.

After calling "resultsAvailable()", the next result (if available) can be either a ResultSet or an UpdateCount if the default "enableResultSetsAndUpdateCount()" was used.

Because of limitations imposed by some DBMSs, it is recommended that for maximum portability, all of the results in a ResultSet object should be retrieved before OUT

JDBC/ODBC eWay Adapter User’s Guide

66

Sun Microsytems, Inc.

Page 66
Image 66
Sun Microsystems JDBC/ODBC Adapter manual Collaboration usability for a stored procedure ResultSet