beautypg.com

Sun Microsystems eWay JDBC/ODBC Adapter User Manual

Page 82

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

82

Sun Microsystems, Inc.

Figure 32 jcdInsert Business Rules

Sample code from the jcdInsert Includes:

package prjJDBC_JCDjcdALL;
public class jcdInsert
{

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, com.stc.connector.appconn.file.FileApplication FileClient_1,
dtd.otdInputDTD_1394195520.DBemployees otdInputDTD_DBemployees_1,
dtd.otdOutputDTD882991309.DBemployee otdOutputDTD_DBemployee_1,
otdJDBC.OtdJDBCOTD otdJDBC_1 )
throws Throwable
{

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

FileClient_1.setText( "Inserting records into db_employee

table .." );
FileClient_1.write();

\\ Unmarshals data from the input XML data into the
otdInputDTD_DBEmployees OTD.

otdInputDTD_DBemployees_1.unmarshalFromString(

input.getText() );

\\ Calls the otdJDBC OTD, and inserts multiple records into the
database via a For Loop. The first insert() method opens the table
ResultSet for insert operations, while the insertRow() method inserts
records into the table ResultSet.

for (int i1 = 0; i1 <

otdInputDTD_DBemployees_1.countX_sequence_A(); i1 += 1) {
otdJDBC_1.getInsert_Ps().setEmp_no(
typeConverter.stringToShort(