Installing Upgrading Designing Configuring Deploying Monitoring Administering Troubleshooting Reference JBI Components
Close Print View
Designing: The Table
 

Classic Java CAPS

Developing Java CAPS Projects

Using SOAP Message Handlers

Creating a Runtime Environment

Designing Business Processes in the Sun Business Process Manager

Working with TCP/IP HL7 Collaborations

Developing Sun Master Indexes (Repository)

Developing Sun Master Patient Indexes

Developing OTDs for Application Adapters

Developing OTDs for Communication Adapters

Developing OTDs for Database Adapters

Developing OTDs for Web Server Adapters

Designing with Application Adapters

Designing with Communication Adapters

Designing with Web Server Adapters

SWIFT Integration Projects

Java EE Based Components

Designing with Sun JCA Adapters

About the TCP/IP JCA Adapter

Defining Constants and Variables

Using Database Operations

Using JDBC/ODBC Operations

JDBC Adapter Database Operations (BPEL)

Activity Input and Output

JDBC Adapter Database Operations (JCD)

The Table

The Stored Procedure

Using Sybase Operations

Sybase Adapter Database Operations (BPEL)

Activity Input and Output

Sybase Adapter Database Operations (JCD)

The Table

The Stored Procedure

Using VSAM Operations

VSAM Adapter Database Operations (BPEL)

Activity Input and Output

VSAM Adapter Database Operations (JCD)

The Table

Prepared Statement

Batch Operations

Using SQL ServerOperations

SQL Server Adapter Database Operations (BPEL)

Activity Input and Output

SQL Server Adapter Database Operations (JCD)

The Table

The Stored Procedure

Using DB2 Operations

DB2 Database Operations (BPEL)

Activity Input and Output

DB2 Database Operations (JCD)

The Table

The Stored Procedure

Using DB2 Connect Operations

DB2 Connect Adapter Database Operations (BPEL)

Activity Input and Output

DB2 Connect Adapter Database Operations (JCD)

The Table

Prepared Statement

The Stored Procedure

Using Oracle Operations

Oracle Adapter Database Operations (BPEL)

Activity Input and Output

Oracle Adapter Outbound XA Support for BPEL

Oracle Adapter Database Operations (JCD)

The Table

The Stored Procedure

Oracle Table Data Types

Long RAW for Prepared Statements and Stored Procedure support:

Using CLOBs

Developing Sun Master Indexes

Using the JMS JCA Wizard

Using the JAXB Wizard and Code-Seeder Pallete

The Table

A table OTD represents a database table. It consists of fields and methods. Fields correspond to the columns of a table while methods are the operations that you can apply to the OTD. This allows you to perform query, update, insert, and delete SQL operations in a table. The ability to update via a resultset is called “Updatable Resultset”, which is a feature supported by this adapter.

By default, the Table OTD has UpdatableConcurrency and ScrollTypeForwardOnly. Normally you do not have to change the default setting.

The type of result returned by the select() method can be specified using:

The Query (Select) Operation
To 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 prjSybase_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.otdOutputDTD1325973702.DB_Employee
     otdOutputDTD_DB_Employee_1, otdSybase.OtdSybaseOTD otdSybase_1,
     com.stc.connector.appconn.file.FileApplication FileClient_1 )
            throws Throwable
        {
            FileClient_1.setText( "Selecting records from db_employee
     table via Table Select........" );
            FileClient_1.write();
            otdSybase_1.getDb_employee().select( input.getText() );
            while (otdSybase_1.getDb_employee(). next()) {
                otdOutputDTD_DB_Employee_1.setEmpNo( typeConverter.
    shortToString( otdSybase_1.getDb_employee().getEMP_NO(), "#",
     false, "" ) );
                otdOutputDTD_DB_Employee_1.setLastname(
     otdSybase_1.getDb_employee().getLAST_NAME() );
                otdOutputDTD_DB_Employee_1.setFirstname(
     otdSybase_1.getDb_employee().getFIRST_NAME() );
                otdOutputDTD_DB_Employee_1.setRate(
     otdSybase_1.getDb_employee().getRATE().toString() );
                otdOutputDTD_DB_Employee_1.setLastDate(
     typeConverter.dateToString( otdSybase_1.getDb_employee().
    getLAST_UPDATE(), "yyyy-MM-dd hh:mm:ss", false, "" ) );
                FileClient_1.setText( otdOutputDTD_DB_Employee_1.
    marshalToString() );
                FileClient_1.write();
            }
            FileClient_1.setText( "Table Select Done." );
            FileClient_1.write();
        }
    
    }
The Insert Operation
To perform an insert operation on a table:
  1. Execute the insert() method. Assign a field.
  2. Insert the row by calling insertRow()

    This example inserts an employee record.

    package prjSybase_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, otdSybase.OtdSybaseOTD otdSybase_1,
         dtd.otdInputDTD_1206505729.DB_Employee otdInputDTD_DB_Employee_1,
     com.stc.connector.appconn.file.FileApplication FileClient_1 )
            throws Throwable
        {
            FileClient_1.setText( "Inserting records in to
     db_employee table......" );
            FileClient_1.write();
            otdInputDTD_DB_Employee_1.unmarshalFromString(
     input.getText() );
            otdSybase_1.getDb_employee().insert();
            for (int i1 = 0; i1 < otdInputDTD_DB_Employee_1.
    countX_sequence_A(); i1 += 1) {
                otdSybase_1.getDb_employee().setEMP_NO(
     typeConverter.stringToShort( otdInputDTD_DB_Employee_1.
    getX_sequence_A( i1 ).getEmpNo(), "#", false, 0 ) );
                otdSybase_1.getDb_employee().setLAST_NAME(
     otdInputDTD_DB_Employee_1.getX_sequence_A( i1 ).getLastname() );
                otdSybase_1.getDb_employee().setFIRST_NAME(
     otdInputDTD_DB_Employee_1.getX_sequence_A( i1 ).getFirstname() );
                otdSybase_1.getDb_employee().setRATE(
     new java.math.BigDecimal( otdInputDTD_DB_Employee_1.
    getX_sequence_A( i1 ).getRate() ) );
                otdSybase_1.getDb_employee().setLAST_UPDATE(
     typeConverter.stringToTimestamp( otdInputDTD_DB_Employee_1.
    getX_sequence_A( i1 ).getLastDate(), "yyyy-MM-dd hh:mm:ss", false, "" ) );
        otdSybase_1.getDb_employee().insertRow();
            }
            FileClient_1.setText( "Insert Done." );
            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 prjSybase_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, otdSybase.OtdSybaseOTD otdSybase_1,
    com.stc.connector.appconn.file.FileApplication FileClient_1 )
            throws Throwable
        {
            FileClient_1.setText( "Updating the Rate and Last_update fields .. " );
            FileClient_1.write();
            otdSybase_1.getDb_employee().update( input.getText() );
            while (otdSybase_1.getDb_employee().next()) {
                otdSybase_1.getDb_employee().setLAST_NAME( "Krishna" );
                otdSybase_1.getDb_employee().setFIRST_NAME( "Kishore" );
                otdSybase_1.getDb_employee().updateRow();
            }
            FileClient_1.setText( "Update Done." );
            FileClient_1.write();
        }
    
    }
The Delete Operation
To perform a delete operation on a table: