Using Generated TIP Connector Classes

The examples in this topic assume the following set-up:

@LIB(

OS2200Path="D:/2200IDE/OS2200.jar",

J2EEPath="c:/sun/appserver/lib/j2ee.jar"

)

@TIP(host="rs02fe",

         port=2700,

         classname="Freshman",

         transactions={@Transaction(name="TW01",view="EMP_BUF"),

  @Transaction(classname="TransTwo",

name="TW02",view="EMP_BUF2")}

)

Example 1

To call the transaction TW01, you could code

TransTW01 T1 = new TransTW01();

String output = T1.callTrans("input data");

The string constant "input data" is passed as a straight parameter to the transaction TW01 and the output is returned in a string "output." This is the simplest call. In this use, the connection is left open. To close it, code

T1.getConnection().closeConnection();

Example 2

To create a connection object for use by the transaction object, allowing for more control of the connection, code

Freshman Fr = new Freshman();

Fr.Connect();

TransTW01 T1 = new TransTW01(Fr);

TransTwo T2 = new TransTwo(Fr);

String out1 = t1.callTrans("trans 1 input");

String out2 =t2.callTrans("trans 2 input");

Fr.closeConnection();

Example 3

To have the connection information acquired at runtime (host and port number are overridden by the user when the connection is created), code

String hostAddress;

String portNumber;

.

.

Get the host address and port number from somewhere.

.

.

Freshman Fr = new Freshman(hostAddress,portNumber);

Fr.Connect();

TransTW01 T1 = new TransTW01(Fr);

TransTwo T2 = new TransTwo(Fr);

String out1 = t1.callTrans("trans 1 input");

String out2 =t2.callTrans("trans 2 input");

Fr.closeConnection();