The common server versions of DB2 support the XA91 specification defined in X/Open CAE Specification Distributed Transaction Processing: The XA Specification manual, with the following exceptions:
The XA specification allows the interface to use asynchronous services where the result of a request can be checked at some later time. The database manager requires the use of the requests to be invoked in synchronous mode.
The XA interface allows for two ways to register an RM: static registration and dynamic registration. The database manager implements dynamic registration which is more advanced and efficient. Refer to "Resource Managers (RM)" for more details about these two methods.
As required by the XA interface, the database manager provides a db2xa_switch external C variable of type xa_switch_t to return the XA switch structure to the TM. Other than the addresses of the various XA functions, the following fields are returned:
The database manager open string has the following syntax:
"database_alias<,username,password>"
The database_alias is required to specify the database alias name of the database. This alias name is the same as the database name unless you have explicitly cataloged an alias name after you created the database. The username and password are optional, and are used to provide authentication information to the database if the database is set up with authentication=SERVER.
The database manager does not use the XA close string and its content will be ignored.
DB2 for Windows NT supports the X/Open XA Interface. However the interface to the db2xa_switch data structure is different for DB2 for Windows NT due to operating system differences.
The pointer to the xa_switch structure, db2xa_switch, is exported as DLL data. This implies that a Windows NT application using this structure must reference it in one of two ways:
#define db2xa_switch (*db2xa_switch)prior to an use of db2xa_switch,
extern __declspec(dllimport) struct xa_switch_t db2xa_switch
DB2 for Windows NT also provides an API, db2xacic, which returns the address of the db2xa_switch structure. This function is prototyped as:
struct xa_switch_t * SQL_API_FN db2xacic( )
The following code illustrates the different ways the db2xa_switch can be accessed via a C program:
#include <stdio.h> #include <xa.h> struct xa_switch_t * SQL_API_FN db2xacic( ); #ifdef DECLSPEC_DEFN extern __declspec(dllimport) struct xa_switch_t db2xa_switch; #else #define db2xa_switch (*db2xa_switch) extern struct xa_switch_t db2xa_switch; #endif main( ) { struct xa_switch_t *foo; printf ("%s \n", db2xa_switch.name ); foo = db2xacic(); printf ( "%s \n", foo->name ); return ; }
DB2 needs to resolve the entry points to ax_reg and ax_unreg with the TM in order to be able to dynamically register a transaction: