DB2 10.5 for Linux, UNIX, and Windows

XA function supported by DB2 for Linux, UNIX, and Windows

DB2® for Linux, UNIX, and Windows supports the XA91 specification defined in X/Open CAE Specification Distributed Transaction Processing: The XA Specification, with the following exceptions:

XA switch usage and location

As required by the XA interface, the database manager provides a db2xa_switch_std and a db2xa_switch_static_std external C variable of type xa_switch_t to return the XA switch structure to the TM. Other than the addresses of various XA functions, the following fields are returned:

Field
Value
name
The product name of the database manager. For example, IBM® DB2 Version 9.7 for AIX®.
flags
For db2xa_switch_std TMREGISTER | TMNOMIGRATE is set

Explicitly states that the DB2 product uses dynamic registration, and that the TM should not use association migration. Implicitly states that asynchronous operation is not supported.

For db2xa_switch_static_std TMNOMIGRATE is set

Explicitly states that the DB2 product uses static registration, and that the TM should not use association migration. Implicitly states that asynchronous operation is not supported.

version
Must be zero.

Using the DB2 for Linux, UNIX, and Windows XA switch

The XA architecture requires that a Resource Manager (RM) provide a switch that gives the XA Transaction Manager (TM) access to the RM's xa_ routines. An RM switch uses a structure called xa_switch_t. The switch contains the RM's name, non-NULL pointers to the RM's XA entry points, a flag, and a version number.

Linux and UNIX

The switch for DB2 for Linux, UNIX, and Windows can be obtained through either of the following two ways:

With either method, you must link your application with libdb2.

Windows

The pointer to the xa_switch structure, db2xa_switch_std, or db2xa_switch_static_std is exported as DLL data. This implies that a Windows application using this structure must reference it in one of three ways:

With any of these methods, you must link your application with db2api.lib.

Example C Code

The following code illustrates the different ways in which the db2xa_switch_std or db2xa_switch_static_std can be accessed via a C program. Be sure to link your application with the appropriate library.

   #include <stdio.h>
   #include <xa.h>

   struct xa_switch_t * SQL_API_FN  db2xacic_std( );

   #ifdef DECLSPEC_DEFN
   extern __declspec(dllimport) struct xa_switch_t db2xa_switch_std;
   #else
   #define db2xa_switch_std (*db2xa_switch_std)
   extern struct xa_switch_t db2xa_switch_std;
   #endif
main( )
   {
      struct xa_switch_t *foo;
      printf ( "switch_std.name );
      foo = db2xacic_std();
      printf ( "name );
      return ;
   }