Sun Adapter for Oracle Tutorials

Using the Collaboration Editor's Java Source Editor

To create the third Java Collaboration, jcdPsSelect, we will use the Java Source Editor. The Java Source Editor allows you to write your business rules in the editor, or copy code into the Collaboration Editor that you have written with another tool.

jcdPsSelect Collaboration Java Code

The completed Java source code for the jcdPsSelect Collaboration appears as follows:


package prjOracle_JCD;


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, 
otdOracle.OtdOracleOTD otdOracle_1, dtd.otdOutputDTD1007064608.
DBemployee otdOutputDTD_DBemployee_1, com.stc.connector.appconn.file.FileApplication 
FileClient_1 )
       throws Throwable
   {
       FileClient_1.setText( "Selecting record(s) from db_employee table via Prepared 
Statement select .." );
       FileClient_1.write();
       otdOracle_1.getSelect_ps().setEmpno( new java.math.BigDecimal( "0" ) );
       otdOracle_1.getSelect_ps().executeQuery();
       if (otdOracle_1.getSelect_ps().resultsAvailable()) {
           while (otdOracle_1.getSelect_ps().get$Select_psResults().next()) {
               otdOutputDTD_DBemployee_1.setEmpNo( otdOracle_1.getSelect_ps().get$Select_psResults().getEMP_NO().toString() );
               otdOutputDTD_DBemployee_1.setLastname( otdOracle_1.getSelect_ps().get$Select_psResults().getLAST_NAME() );
               otdOutputDTD_DBemployee_1.setFirstname( otdOracle_1.getSelect_ps().get$Select_psResults().getFIRST_NAME() );
               otdOutputDTD_DBemployee_1.setRate( Double.toString( otdOracle_1.getSelect_ps().get$Select_psResults().getRATE() ) );
               otdOutputDTD_DBemployee_1.setLastDate( otdOracle_1.getSelect_ps().get$Select_psResults().getLAST_UPDATE().toString() );
               FileClient_1.setText( otdOutputDTD_DBemployee_1.marshalToString() );
               FileClient_1.write();
           }
       } else {
           FileClient_1.setText( "No record found!" );
           FileClient_1.write();
       }
       FileClient_1.setText( "Done Select." );
       FileClient_1.write();
   }

} 

Note –

The above code has been wrapped for display purposes.