Chapter 13 Creating CORBA-Compatible Java Clients
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.
The following table lists the datatypes displayed in Jaguar Manager, the equivalent CORBA IDL types, and the Java datatypes used in stub methods.
Jaguar Manager, CORBA IDL, and Java datatype equivalence
Null 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 |
The com.sybase.CORBA.jdbc11 classes require a JDK-1.1-compatible virtual machine. The package com.sybase.CORBA.jdbc102 provides equivalent classes for use in a JDK-1.0.2-compatible virtual machine. Chapter 1, "Java Classes and Interfaces" in the Jaguar CTS 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 ResultSet" 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 Jaguar 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.
CORBA Any and TypeCode support Jaguar'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.
For 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.
In Jaguar 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 ...
}
See the Jaguar tutorials and the examples provided with your Jaguar software for example method calls. Jaguar CTS Getting Started for your platform 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.
Copyright © 2000 Sybase, Inc. All rights reserved. |