Chapter 6

Section 6.5

Implementing the JDBC/ODBC eWay Sample Projects

Building and Deploying the prjJDBC_JCD Sample Project

Figure 34 jcdTableSelect Business Rules

Sample code from the jcdTableSelect Includes:

package prjJDBC_JCDjcdALL; public class jcdTableSelect

{

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, dtd.otdInputDTD_1394195520.DBemployees otdInputDTD_DBemployees_1, 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 table select .." );

FileClient_1.write();

\\Copies the database resultset into the otdInputDTD_DBEmployee (XML OTD) and selects all available records from the database that meet a certain criteria. Checking the next() method ensures all rows are retrieved in the while loop.

otdJDBC_1.getDB_EMPLOYEE().select( input.getText() ); while (otdJDBC_1.getDB_EMPLOYEE().next()) {

otdOutputDTD_DBemployee_1.setEmpNo( typeConverter.shortToString( otdJDBC_1.getDB_EMPLOYEE().getEMP_NO(), "#", false, "" ) );

otdOutputDTD_DBemployee_1.setLastname( otdJDBC_1.getDB_EMPLOYEE().getLAST_NAME() );

otdOutputDTD_DBemployee_1.setFirstname( otdJDBC_1.getDB_EMPLOYEE().getFIRST_NAME() );

JDBC/ODBC eWay Adapter User’s Guide

86

Sun Microsystems, Inc.

Page 86
Image 86
Sun Microsystems JDBC/ODBC Adapter manual JcdTableSelect Business Rules, Sample code from the jcdTableSelect Includes