Using Database Operations

ProcedureTo perform a query operation on a table:

  1. Execute the select() method with the “where” clause specified if necessary.

  2. Loop through the ResultSet using the next() method.

  3. Process the return record within a while() loop.

    For example:


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