Chapter 5
Section 5.2
Using JDBC/ODBC Operations
JDBC eWay Database Operations (JCD)
JDBC/ODBC eWay Adapter User’s Guide
62
Sun Microsytems, Inc.
otdInputDTD_DBemployees_1.unmarshalFromString(
input.getText() );
for (int i1 = 0; i1 <
otdInputDTD_DBemployees_1.countX_sequence_A(); i1 += 1) {
otdJDBC_1.getInsert_Ps().setEmp_no(
typeConverter.stringToShort(
otdInputDTD_DBemployees_1.getX_sequence_A( i1 ).getEmpNo(), "#",
false, 0 ) );
otdJDBC_1.getInsert_Ps().setLast_name(
otdInputDTD_DBemployees_1.getX_sequence_A( i1 ).getLastname() );
otdJDBC_1.getInsert_Ps().setFirst_name(
otdInputDTD_DBemployees_1.getX_sequence_A( i1 ).getFirstname() );
otdJDBC_1.getInsert_Ps().setRate( new
java.math.BigDecimal( otdInputDTD_DBemployees_1.getX_sequence_A( i1
).getRate() ) );
otdJDBC_1.getInsert_Ps().setLast_update(
typeConverter.stringToSQLDate(
otdInputDTD_DBemployees_1.getX_sequence_A( i1 ).getLastDate(), "yyyy-
MM-dd hh:mm:ss", false, "" ) );
otdJDBC_1.getInsert_Ps().executeUpdate();
}
FileClient_1.setText( "Done Insert." );
FileClient_1.write();
}
}
The Update Operation
To perform an update operation on a table:
1
Execute the
update()
method.
2
Using a while loop together with
next()
, move to the row that you want to update.
3
Assign updating value(s) to the fields of the table OTD
4
Update the row by calling
updateRow()
.
package prjJDBC_JCDjcdALL;
public class jcdUpdate
{
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, dtd.otdInputDTD_1394195520.DBemployees
otdInputDTD_DBemployees_1,
com.stc.connector.appconn.file.FileApplication FileClient_1 )
throws Throwable
{
FileClient_1.setText( "Update the Rate and Last_update fields
using Prepared Statement.. " );
FileClient_1.write();