Chapter 5

Section 5.2

Using JDBC/ODBC Operations

JDBC eWay Database Operations (JCD)

{

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

FileClient_1.write();

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() );

otdOutputDTD_DBemployee_1.setRate( otdJDBC_1.getDB_EMPLOYEE().getRATE().toString() );

otdOutputDTD_DBemployee_1.setLastDate( typeConverter.dateToString( otdJDBC_1.getDB_EMPLOYEE().getLAST_UPDATE(), "yyyy-MM-dd hh:mm:ss", false, "" ) );

FileClient_1.setText( otdOutputDTD_DBemployee_1.marshalToString() ); FileClient_1.write();

}

FileClient_1.setText( "Done table select." ); FileClient_1.write();

}

}

The Insert Operation

To perform an insert operation on a table:

1Execute the insert() method. Assign a value to a field.

2Insert the row by calling insertRow()

This example inserts an employee record.

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

{

FileClient_1.setText( "Inserting records into db_employee table .." );

FileClient_1.write();

JDBC/ODBC eWay Adapter User’s Guide

61

Sun Microsytems, Inc.

Page 61
Image 61
Sun Microsystems JDBC/ODBC Adapter manual Insert Operation, To perform an insert operation on a table