Oracle8i CORBA Developer's Guide and Reference
Release 3 (8.1.7)

Part Number A83722-01

Library

Product

Contents

Index

Go to previous page Go to beginning of chapter Go to next page

JTA Server-Side Demarcation

To retrieve any objects or database resources, you can perform in-session activation or remote lookup.

Example 7-1 Server-Side Demarcation for Single-Phase Commit

Before starting the client, you must first bind the UserTransaction and DataSource objects in the namespace.

Bind UserTransaction Object in the Namespace

You bind the UserTransaction object in the namespace through the bindut command of the sess_sh tool. To bind a UserTransaction object to the name "/test/myUT" in the namespace located on nsHost, execute the following:

sess_sh -service jdbc:oracle:thin:@nsHost:5521:ORCL -user SCOTT -password TIGER
& bindut /test/myUT

Verify that the user bound with the UserTransaction has FORCE ANY TRANSACTION granted to the user that bound this object. This privilege enables the user to commit this transaction. In this example, you would execute the following:

GRANT FORCE ANY TRANSACTION TO SCOTT


Note:

The client needs the same information to retrieve the UserTransaction as you give within the bindut command.  


Bind DataSource Object in the Namespace

Use the bindds command of the sess_sh tool to bind an DataSource object in the namespace. The full command is detailed in the Oracle8i Java Tools Reference.

To bind a DataSource object for a single-phase commit transaction with the empHost database to the name "/test/empDatabase" in the namespace located on nsHost, execute the following:

sess_sh -service jdbc:oracle:thin:@nsHost:5521:ORCL -user SCOTT -password TIGER
& bindds /test/empDatabase -url jdbc:oracle:thin:@empHost:5521:ORCL -dstype jta

After binding the DataSource object in the namespace, the server can enlist the database within a global transaction.


Note:

If using more than one database, you will need to setup for a two-phase commit. See "Configuring Two-Phase Commit Engine" for more information.  


Developing the Server Application

The following example demonstrates a server object performing an in-session lookup of the UserTransaction and DataSource objects. This example uses a single phase commit transaction.


Note:

To modify this for two-phase commit, supply a username and password within the environment passed into the initial context constructor.  


ic = new InitialContext ( );

// lookup the usertransaction
UserTransaction ut = (UserTransaction)ic.lookup ("/test/myUT");
...
ut.begin ();

// Retrieve the DataSource 
DataSource ds = (DataSource)ic.lookup ("/test/empDB");

// Get connection to the database through DataSource.getConnection
Connection conn = ds.getConnection ();


Go to previous page
Go to beginning of chapter
Go to next page
Oracle
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index