| Oracle8i CORBA Developer's Guide and Reference Release 3 (8.1.7) Part Number A83722-01 |
|
To retrieve any objects or database resources, you can perform in-session activation or remote lookup.
UserTransaction is always local (only necessary for bean-managed transactional beans), and DataSource objects can be local or remote. For local retrieval of any of these objects, you can activate these objects within this session. The namespace is always local, so the lookup requires only the JNDI name, In addition, the initial context can be created without any set environment.
DataSource object is remote, so you must still provide all of the same information that was provided in the client scenario: authentication information, namespace URL, the "jdbc_access://" prefix, and registering the OracleDriver. For remote retrieval, perform exactly as demonstrated in the "JTA Client-Side Demarcation".
Before starting the client, you must first bind the UserTransaction and DataSource objects 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
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. |
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.
ic = new InitialContext ( ); // lookup the usertransaction UserTransaction ut = (UserTransaction)ic.lookup ("/test/myUT"); ... ut.begin ();// Retrieve the DataSourceDataSource ds = (DataSource)ic.lookup ("/test/empDB");// Get connection to the database through DataSource.getConnectionConnection conn = ds.getConnection ();
|
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|