beautypg.com

Sun Microsystems eWay JDBC/ODBC Adapter User Manual

Page 84

background image

Chapter 6

Section 6.5

Implementing the JDBC/ODBC eWay Sample Projects

Building and Deploying the prjJDBC_JCD Sample Project

JDBC/ODBC eWay Adapter User’s Guide

84

Sun Microsystems, Inc.

Figure 33 jcdPsSelect Business Rules

Sample code from the jcdPsSelect Includes:

package prjJDBC_JCDjcdALL;

public class jcdPsSelect
{

public com.stc.codegen.logger.Logger logger;
public com.stc.codegen.alerter.Alerter alerter;
public com.stc.codegen.util.CollaborationContext collabContext;
public com.stc.codegen.util.TypeConverter typeConverter;

public void receive( com.stc.connector.appconn.file.FileTextMessage
input, otdJDBC.OtdJDBCOTD otdJDBC_1,
dtd.otdOutputDTD882991309.DBemployee otdOutputDTD_DBemployee_1,
com.stc.connector.appconn.file.FileApplication FileClient_1 )
throws Throwable
{

\\ Writes out a message stating records are being selected.

FileClient_1.setText( "Selecting record(s) from db_employee
table via Prepared Statement select .." );

\\ Copies the database resultset into the otdInputDTD_DBEmployee OTD
and selects all available records from the database. The
executeQuery() method executes the prepared statement query, while
the resultsAvailable() method ensures all rows are retrieved in the
while loop.

FileClient_1.write();

otdJDBC_1.getSelect_ps().setEmp_no( Short.parseShort( "0" ) );
otdJDBC_1.getSelect_ps().executeQuery();
if (otdJDBC_1.getSelect_ps().resultsAvailable()) {
while
(otdJDBC_1.getSelect_ps().get$Select_psResults().next()) {