Executing component methods

After instantiating the stub class, use the stub class instance to invoke the component’s methods. Each method in the stub interface corresponds to a method in the component interface that you have narrowed the proxy object to.

Parameter and return datatypes

The following table lists the datatypes displayed in EAServer Manager, the equivalent CORBA IDL types, and the Java datatypes used in stub methods.

Table 12-3: EAServer Manager, CORBA IDL, and Java datatype equivalence

EAServer Manager display datatype

CORBA IDL type

IDL Java type (input parameter or return value)

IDL Java type (inout or out parameter)

integer<16>

short

short

org.omg.CORBA.ShortHolder

integer<32>

long

int

org.omg.CORBA.IntHolder

integer<64>

long long

long

org.omg.CORBA.LongHolder

float

float

float

org.omg.CORBA.FloatHolder

double

double

double

org.omg.CORBA.DoubleHolder

boolean

boolean

boolean

org.omg.CORBA.BooleanHolder

string

string

java.lang.String

org.omg.CORBA.StringHolder

binary

BCD::Binary

byte[ ]

BCD.BinaryHolder

decimal

BCD::Decimal

BCD.Decimal

BCD.DecimalHolder

money

BCD::Money

BCD.Money

BCD.MoneyHolder

date

MJD::Date

MJD.Date

MJD.DateHolder

time

MJD::Time

MJD.Time

MJD.TimeHolder

timestamp

MJD::Timestamp

MJD.Timestamp

MJD.TimestampHolder

ResultSet

TabularResults:: ResultSet

TabularResults. ResultSet

TabularResults.ResultSetHolder

ResultSets

TabularResults:: ResultSets

TabularResults. ResultSet[ ]

TabularResults.ResultSetsHolder

NoteNull parameter values are not supported for input or inout parameters. Use an output parameter instead. For input parameters that extend java.lang.Object, you must pass an initialized object of the indicated type. When using holder objects to pass inout parameters, you must set the holder object’s value field to a valid object reference or use the holder constructor that takes an initial value.

Binary, fixed-point, date/time, and ResultSet types The BCD and MJD IDL modules define types to represent common database column types such as binary data, fixed-point numeric data, dates, and times. The BCD::Binary CORBA type maps to a Java byte array. The other BCD and MJD types map to data representations that are optimized for network transport.

To convert between the IDL-mapped datatypes and from core java.* classes, use these classes from the com.sybase.CORBA.jdbc11 package:

Class

Description

SQL

Contains methods to convert from BCD.* and MJD.* types to java.* types

IDL

Contains methods to convert from java.* types to BCD.* and MJD.* types

Chapter 1, “Java Classes and Interfaces,” in the EAServer API Reference provides reference pages for these classes.

ResultSet types The TabularResults IDL module defines types used to represent tabular data. Result sets are typically used only as return types, though you can pass them as parameters. “Methods that return tabular results” describes how to process result sets returned by method calls.

User-defined IDL types A user-defined type is any type that is not in the set of predefined datatypes and is not one of the CORBA IDL base types. You can define methods with user-defined types in EAServer Manager, as described in “User-defined IDL datatypes”.

If a method definition includes user-defined types, the stub method will use the equivalent Java datatype as specified by the CORBA Java language mappings specification. See “Overview” for more information on this document.

NoteCORBA Any and TypeCode support EAServer’s Java ORB supports the CORBA Any and TypeCode datatypes. Refer to the OMG CORBA 2.3 specification and IDL to Java Language Mapping Specification (formal/99-07-53) for information on using these types.

Holder classes All Java types have an accompanying holder class that is used for passing parameters by reference. Each holder class has the following structure:

public class <Type>Holder {
    // Current value
    public <type> value;
    // Default constructor
    public <Type>Holder() {}
    // Constructor that sets initial value
    public <Type>Holder(<type> v) {
      this.value = v;
    }
}

This structure is defined by the CORBA Java-language bindings specification.

NoteFor inout parameters, you must pass a non-null value for the parameter input value. Otherwise, method calls fail and throw an exception (NullPointerException). Use out parameters in the method definition if you do not care about the parameter’s input value.

Methods that return tabular results

In EAServer Manager, a method’s property sheet indicates whether the method returns zero, one, or multiple result sets. This setting determines the return code of the stub method as follows:

The TabularResults IDL module defines the TabularResults::ResultSet CORBA IDL datatype, which maps to TabularResults.ResultSet in Java. Most applications will convert objects of this type to a java.sql.ResultSet by calling one of the following methods:

After converting the result set to java.sql.ResultSet, use standard JDBC calls to retrieve the rows and columns. Alternatively, pass the result set to a data-aware control that displays the data to the end user.

The example below calls a stub method returnsRows() that returns a single result set:

import com.sybase.CORBA.jdbc11.SQL;
...
    java.sql.ResultSet rs = 
       SQL.getResultSet(myStub.returnsRows());
    ... code to process rows or pass result set
        to a data-aware control ...

The example below calls a stub method returnsResults() which returns multiple result sets:

import com.sybase.CORBA.jdbc11.SQL;
...
  java.sql.ResultSet rs;
  TabularResults.ResultSet[] trs_array = 
      myStub.returnsResults();

  for (int i = 0; i < trs_array.length; i++)
  {
    rs = SQL.getResultSet(trs_array[i]);
    ... code to process rows or pass result set
        to a data-aware control ...
  }

Example method calls

See the EAServer tutorials and the examples provided with your EAServer software for example method calls. Chapter 2, “Creating CORBA Java Components and Clients,” in the EAServer Cookbook contains tutorials with sample Java clients.

An introductory sample Java client is provided in the html/classes/Sample/Intro subdirectory. The file readme.html in that directory describes how to compile the classes, install the required component, and run the sample client.