This feature provides a standard Java API for performing distributed transactions with either Adaptive Server version 12.x or version 11.x with XA-Server.
This feature is designed for use in a large multitier
environment.
See Chapter 7, “Distributed Transactions,” in the JDBC 2.0 Optional Package (formerly the JDBC 2.0 Standard Extension API).
javax.sql.XADataSource
javax.sql.XAConnection
javax.transaction.xa.XAResource
Because jConnect is communicating directly with the resource manager within Sybase Adaptive Server version 12.0 and later, the installation must have Distributed Transaction Management support.
Any user that wants to participate in a distributed transaction must have the “dtm_tm_role” granted to them or the transactions will fail.
To use distributed transactions, you must install the stored procedures in the /sp directory. Refer to “Installing Stored Procedures” in Chapter 1 of your jConnect for JDBC Installation Guide.
Figure 2-2: Distributed transaction management support with version 12.x
jConnect also provides a standard Java API for performing distributed transactions with Adaptive Server version 11.x as your database server.
This implementation works only with Sybase Adaptive Server version 11.x and XA-Server 11.1.
Figure 2-3: Distributed transaction management support with version 11.x
The login chosen cannot have a default login database of master, model, or sybsystemdb. This is because XA-Server connects only when the user's work is associated with a distributed transaction, and distributed transactions are not permitted on those databases.
There is no access to metadata. While this restricts the client, it is most likely not the part of the API being used within the boundaries of distributed transactions.
This approach is the same as “1a. Configuration by administrator: LDAP”described in “JNDI for naming databases”, except that you enter an additional line to the LDIF entry. In the following example, the added line of code is displayed in bold.
dn:servername:myASE, o=MyCompany, c=US 1.3.6.1.4.1.897.4.2.5:TCP#1# mymachine 4000 1.3.6.1.4.1.897.4.2.10:PACKETSIZE=1024&user=me&password=secret 1.3.6.1.4.1.897.4.2.11:userdb 1.3.6.1.4.1.897.4.2.18:XADataSource
This procedure initializes three properties (INITIAL_CONTEXT_FACTORY, PROVIDER_URL, and OBJECT_FACTORIES), and retrieves a XADataSource object. For example:
... XADataSource xads = (XADatasource) ctx.lookup("servername=myASE"); XAConnection xaconn = xads.getXAConnection();
or override the default settings for the user name and password:
... XADataSource xads = (XADatasource) ctx.lookup("servername=myASE"); XAConnection xaconn = xads.getXAConnection("my_username","my_password");
This approach is the same as “1a. Configuration by administrator: LDAP”described in “JNDI for naming databases”, except that you enter an additional three lines to the LDIF entry.
In the following example, the additional code lines are displayed in bold.
dn:servername:myASE, o=MyCompany, c=US 1.3.6.1.4.1.897.4.2.5:TCP#1# mymachine 4000 1.3.6.1.4.1.897.4.2.10:PACKETSIZE=1024&user=me&password=secret 1.3.6.1.4.1.897.4.2.11:userdb 1.3.6.1.4.1.897.4.2.16:userconnection 1.3.6.1.4.1.897:4.2.17:1 1.3.6.1.4.1.897.4.2.18:XADataSource
where . . .4.2.17:1
indicates
that jConnect is going to connect to an XA-Server and userconnection
corresponds
to the Logical Resource Manager (LRM) to use. XA-Server has an xa_config file
that contains these entries:
[xa]
lrm=userconnection server=my_ase_11_server XAServer=my_xa_server
Figure 2-4: Distributed transaction management support sample configuration
See the XA-Server documentation for details on how to write an xa_config file.
This procedure initializes three properties (INITIAL_CONTEXT_FACTORY, PROVIDER_URL, and OBJECT_FACTORIES), and retrieves a XADataSource object. For example:
... XADataSource xads = (XADatasource) ctx.lookup("servername=myASE"); XAConnection xaconn = xads.getXAConnection();
With Adaptive Server 11.x, you cannot override the default user name and password; that is, you cannot call:
xads.getXAConnection("my_username","my_password");
because the lrm is associated with a specific user name and password.
Copyright © 2003. Sybase Inc. All rights reserved. |
![]() |