Administration Guide


Configuring XA Transaction Managers to Use DB2 UDB

The sections that follow describe how to configure specific products to use DB2 as a resource manager. You can use any of the following:

Configuring IBM TXSeries CICS

For information about how to configure IBM TXSeries CICS to use DB2 as a resource manager, refer to your IBM TXSeries CICS Administration Guide. TXSeries documentation can be viewed online at http://www.transarc.com/Library/documentation/websphere/WAS-EE/en_US/html/.

Host and AS/400 database servers can participate in CICS-coordinated transactions.

Configuring IBM TXSeries Encina

Following are the various APIs and configuration parameters required for the integration of Encina Monitor and DB2 Universal Database servers, or DB2 for MVS, DB2 for OS/390, DB2 for AS/400, or DB2 for VSE&VM when accessed through DB2 Connect. TXSeries documentation can be viewed online at http://www.transarc.com/Library/documentation/websphere/WAS-EE/en_US/html/.

Host and AS/400 database servers can participate in Encina-coordinated transactions.

Configuring DB2

To configure DB2:

  1. Each database name must be defined in the DB2 database directory. If the database is a remote database, a node directory entry must also be defined. You can perform the configuration using the Client Configuration Assistant (CCA), or the DB2 command line processor (CLP). For example:
       DB2 CATALOG DATABASE inventdb AS inventdb AT NODE host1 AUTH SERVER
       DB2 CATALOG TCPIP NODE host1 REMOTE hostname1 SERVER svcname1
    
  2. The DB2 client can optimize its internal processing for Encina if it knows that it is dealing with Encina. You can specify this by setting the tp_mon_name database manager configuration parameter to ENCINA. The default behavior is no special optimization. If tp_mon_name is set, the application must ensure that the thread that performs the unit of work also immediately commits the work after ending it. No other unit of work may be started. If this is not your environment, ensure that the tp_mon_name value is NONE (or, through the CLP, that the value is set to NULL). The parameter can be updated through the Control Center or the CLP. The CLP command is:
       db2 update dbm cfg using tp_mon_name ENCINA
    

Configuring Encina for Each Resource Manager

To configure Encina for each resource manager (RM), an administrator must define the Open String, Close String, and Thread of Control Agreement for each DB2 database as a resource manager before the resource manager can be registered for transactions in an application. The configuration can be performed using the Enconcole full screen interface, or the Encina command line interface. For example:

   monadmin create rm inventdb -open "db=inventdb,uid=user1,pwd=password1"

There is one resource manager configuration for each DB2 database, and each resource manager configuration must have an rm name ("logical RM name"). To simplify the situation, you should make it identical to the database name.

The xa_open string contains information that is required to establish a connection to the database. The content of the string is RM-specific. The xa_open string of DB2 UDB contains the alias name of the database to be opened, and optionally, a user ID and password to be associated with the connection. Note that the database name defined here must also be cataloged into the regular database directory required for all database access. For information about DB2's xa_open string, see Setting Up a Database as a Resource Manager.

The xa_close string is not used by DB2.

The Thread of Control Agreement determines if an application agent thread can handle more than one transaction at a time. DB2 UDB supports the default of TMXA_SERIALIZE_ALL_OPERATIONS, where a thread can be reused only after a transaction has completed.

If you are accessing DB2 for OS/390, DB2 for MVS, DB2 for AS/400, or DB2 for VSE&VM, you must use the DB2 Syncpoint Manager. Refer to the DB2 Connect Enterprise Edition for OS/2 and Windows Quick Beginnings manual for configuration instructions.

Referencing a DB2 Database from an Encina Application

To reference a DB2 database from an Encina application:

  1. Use the Encina Scheduling Policy API to specify how many application agents can be run from a single TP monitor application process. For example:
       rc = mon_SetSchedulingPolicy (MON_EXCLUSIVE)
    

    For DB2 (DB2 Universal Database, host, or AS/400 database servers), you should use the default setting of MON_EXCLUSIVE. This ensures that:

    Note:If you are using the ODBC or DB2 Call Level Interface, you must disable multithread support. You can do this by setting the CLI configuration parameter DISABLEMULTITHREAD = 1 (disables multithreading). The default for DB2 Universal Database is DISABLEMULTITHREAD = 0 (enables multithreading). Refer to the CLI Guide and Reference for more information.
  2. Use the Encina RM Registration API to provide the XA switch and the logical RM name to be used by Encina when referencing the RM in an application process. For example:
       rc = mon_RegisterRmi ( &db2xa_switch,   /* xa switch */
                              "inventdb",      /* logical RM name */
                              &rmiId );        /* internal RM ID */
    

    The XA switch contains the addresses of the XA routines in the RM that the TM can call, and it also specifies the functionality that is provided by the RM. The XA switch of DB2 Universal Database is db2xa_switch, and it resides in the DB2 client library (db2app.dll on Windows operating systems and OS/2, and libdb2 on UNIX based systems).

    The logical RM name is the one used by Encina, and is not the actual database name that is used by the SQL application that runs under Encina. The actual database name is specified in the xa_open string in the Encina RM Registration API. The logical RM name is set to be the same as the database name in this example.

    The third parameter returns an internal identifier or handle that is used by the TM to reference this connection.

Note:When using Encina for transaction processing with DB2 through the TM-XA interface, note that Encina-nested transactions are not currently supported by the DB2 XA interface. Avoid using these transactions, if possible. If you cannot, ensure that SQL work is done in only one member of the Encina transaction family.

Configuring BEA Tuxedo

To configure Tuxedo to use DB2 as a resource manager, perform the following steps:

  1. Install Tuxedo as specified in the documentation for that product. Ensure that you perform all basic Tuxedo configuration, including the log files and environment variables.

    You also require a compiler and the DB2 Application Development Client. Install these if necessary.

  2. At the Tuxedo server ID, set the DB2INSTANCE environment variable to reference the instance that contains the databases that you want Tuxedo to use. Set the PATH variable to include the DB2 program directories. Confirm that the Tuxedo server ID can connect to the DB2 databases.
  3. Update the tp_mon_name database manager configuration parameter with the value TUXEDO.
  4. Add a definition for DB2 to the Tuxedo resource manager definition file. In the examples that follow, UDB_XA is the locally-defined Tuxedo resource manager name for DB2, and db2xa_switch is the DB2-defined name for a structure of type xa_switch_t:
  5. Build the Tuxedo transaction monitor server program for DB2:
  6. Build the application servers. In the examples that follow, the -r option specifies the resource manager name, the -f option (used one or more times) specifies the files that contain the application services, the -s option specifies the application service names for this server, and the -o option specifies the output server file name:
  7. Set up the Tuxedo configuration file to reference the DB2 server. In the *GROUPS section of the UDBCONFIG file, add an entry similar to:
       UDB_GRP   LMID=simp GRPNO=3
         TMSNAME=TMS_UDB TMSCOUNT=2
         OPENINFO="UDB_XA:db=sample,uid=db2_user,pwd=db2_user_pwd"
    
    where the TMSNAME parameter specifies the transaction monitor server program that you built previously, and the OPENINFO parameter specifies the resource manager name. This is followed by the database name, and the DB2 user and password, which are used for authentication.

    The application servers that you built previously are referenced in the *SERVERS section of the Tuxedo configuration file.

  8. If the application is accessing data residing on DB2 for OS/390, DB2 for OS/400, or DB2 for VM&VSE, the DB2 Connect XA concentrator will be required. For configuration details and limitations, refer to the DB2 Connect User's Guide.
  9. Start Tuxedo:
       tmboot -y
    
    After the command completes, Tuxedo messages should indicate that the servers are started. In addition, if you issue the DB2 command LIST APPLICATIONS ALL, you should see two connections (in this situation, specified by the TMSCOUNT parameter in the UDB group in the Tuxedo configuration file, UDBCONFIG.

Configuring Microsoft Transaction Server

DB2 UDB V5.2 and later can be fully integrated with Microsoft Transaction Server (MTS) Version 2.0. Applications running under MTS on Windows 32-bit operating systems can use MTS to coordinate two-phase commit with multiple DB2 UDB, host, and AS/400 database servers, as well as with other MTS-compliant resource managers.

Enabling MTS Support in DB2

Microsoft Transaction Server support is automatically enabled. While you can set the tp_mon_name database manager configuration parameter to MTS, it is not necessary and will be ignored.
Note:Additional technical information may be provided on the IBM web site to assist you with installation and configuration of DB2 MTS support. Set your URL to http://www.ibm.com/software/data/db2/library/ , and search for a DB2 Universal Database "Technote" with the keyword "MTS".

MTS Software Prerequisites

MTS support requires the DB2 Client Application Enabler (CAE) Version 5.2, or later, and MTS must be at Version 2.0 with Hotfix 0772 or later releases.

The installation of the DB2 ODBC driver on Windows 32-bit operating systems will automatically add a new keyword into the registry:

  HKEY_LOCAL_MACHINE\software\ODBC\odbcinit.ini\IBM DB2 ODBC Driver:
  Keyword Value Name: CPTimeout
  Data Type: REG_SZ
  Value: 60

Installation and Configuration

Following is a summary of installation and configuration considerations for MTS. To use DB2's MTS support, you must:

  1. Install MTS and the DB2 client on the same machine where the MTS application runs.
  2. If host or AS/400 database servers are to be involved in a multisite update:
    1. Install DB2 Connect Enterprise Edition (EE), either on your local machine or on a remote machine. DB2 Connect EE allows host or AS/400 database servers to participate in a multisite update transaction.
    2. Ensure that your DB2 Connect EE server is enabled for multisite update. For information about enabling DB2 Connect for multisite updates, refer to the DB2 Connect Enterprise Edition Quick Beginnings manual for your platform.

When running DB2 CLI/ODBC applications, the following configuration keywords (as set in the db2cli.ini file) must not be changed from their default values:

DB2 CLI applications written to make use of MTS support must not change the attribute values corresponding to the above keywords. In addition, the applications must not change the default values of the following attributes:

Note:Additional technical information may be provided on the IBM web site to assist you with installation and configuration of DB2 MTS support. Set your URL to http://www.ibm.com/software/data/db2/library/ , and search for a DB2 Universal Database "Technote" with the keyword "MTS".

Verifying the Installation

  1. Configure your DB2 client and DB2 Connect EE to access your DB2 UDB, host, or AS/400 server.
  2. Verify the connection from the DB2 CAE machine to the DB2 UDB database servers.
  3. Verify the connection from the DB2 Connect machine to your host or AS/400 database server with DB2 CLP, and issue a few queries.
  4. Verify the connection from the DB2 CAE machine through the DB2 Connect gateway to your host or AS/400 database server, and issue a few queries.

Supported DB2 Database Servers

The following servers are supported for multisite update using MTS-coordinated transactions:

MTS Transaction Time-Out and DB2 Connection Behavior

You can set the transaction time-out value in the MTS Explorer tool. For more information, refer to the online MTS Administrator Guide.

If a transaction takes longer than the transaction time-out value (default value is 60 seconds), MTS will asynchronously issue an abort to all Resource Managers involved, and the whole transaction is aborted.

For the connection to a DB2 server, the abort is translated into a DB2 rollback request. Like any other database request, the rollback request is serialized on the connection to guarantee the integrity of the data on the database server.

As a result:

Connection Pooling

Connection pooling enables an application to use a connection from a pool of connections, so that the connection does not need to be re-established for each use. Once a connection has been created and placed in a pool, an application can reuse that connection without performing a complete connection process. The connection is pooled when the application disconnects from the ODBC data source, and will be given to a new connection whose attributes are the same.

Connection pooling has been a feature of ODBC driver Manager 2.x. With the latest ODBC driver manager (version 3.5) that was shipped with MTS, connection pooling has some configuration changes and new behavior for ODBC connections of transactional MTS COM objects (see Reusing ODBC Connections Between COM Objects Participating in the Same Transaction).

ODBC driver Manager 3.5 requires that the ODBC driver register a new keyword in the registry before it allows connection pooling to be activated. The keyword is:

  Key Name: SOFTWARE\ODBC\ODBCINST.INI\IBM DB2 ODBC DRIVER
  Name: CPTimeout
  Type: REG_SZ
  Data: 60

The DB2 ODBC driver Version 6 and later for the 32-bit Windows operating system fully supports connection pooling; therefore, this keyword is registered. Version 5.2 clients must install FixPack 3 (WR09024) or later.

The default value of 60 means that the connection will be pooled for 60 seconds before it is disconnected.

In a busy environment, it is better to increase the CPTimeout value to a large number (Microsoft sometimes suggests 10 minutes for certain environments) to prevent too many physical connects and disconnects, because these consume large amounts of system resource, including system memory and communications stack resources.

In addition, to ensure that the same connection is used between objects in the same transaction in a multiple processor machine, you must turn off "multiple pool per processor" support. To do this, copy the following registry setting into a file called odbcpool.reg, save it as a plain text file, and issue the command odbcpool.reg. The Windows operating system will import these registry settings.

REGEDIT4 
 
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Connection Pooling] 
"NumberOfPools"="1"

Without this keyword set to 1, MTS may pool connections in different pools, and hence will not reuse the same connection.

MTS Connection Pooling using ADO 2.1 and Later

If the MTS COM objects use ADO to access the database, you must turn off the OLEDB resource pooling so that the Microsoft OLEDB provider for ODBC (MSDASQL) will not interfere with ODBC connection pooling. This feature was initialized to OFF in ADO 2.0, but is initialized to ON in ADO 2.1. To turn OLEDB resource polling off, copy the following lines into a file called oledb.reg, save it as a plain text file, and issue the command oledb.reg. The Windows operating system will import this registry setting.

REGEDIT4 
 
[HKEY_CLASSES_ROOT\CLSID\{c8b522cb-5cf3-11ce-ade5-00aa0044773d}] 
@="MSDASQL" 
"OLEDB_SERVICES"=dword:fffffffc

Reusing ODBC Connections Between COM Objects Participating in the Same Transaction

ODBC connections in MTS COM objects have connection pooling turned on automatically (whether or not the COM object is transactional).

For multiple MTS COM objects participating in the same transaction, the connection can be reused between two or more COM objects in the following manner.

Suppose that there are two COM objects, COM1 and COM2, that connect to the same ODBC data source and participate in the same transaction.

After COM1 connects and does its work, it disconnects, and the connection is pooled. However, this connection will be reserved for the use of other COM objects of the same transaction. It will be available to other transactions only after the current transaction ends.

When COM2 is invoked in the same transaction, it is given the pooled connection. MTS will ensure that the connection can only be given to the COM objects that are participating in the same transaction.

On the other hand, if COM1 does not explicitly disconnect, it will tie up the connection until the transaction ends. When COM2 is invoked in the same transaction, a separate connection will be acquired. Subsequently, this transaction ties up two connections instead of one.

This reuse of connection feature for COM objects participating in the same transaction is preferable for the following reasons:

Tuning TCP/IP Communications

If a small CPTimeout value is used in a high-workload environment where too many physical connects and disconnects occur at the same time, the TCP/IP stack may encounter resource constraints.

To alleviate this problem, use the TCP/IP Registry Entries. These are described in the Windows NT Resource Guide, Volume 1. The registry key values are located in HKEY_LOCAL_MACHINE--> SYSTEM--> CurrentControlSet--> Services--> TCPIP--> Parameters.

The default values and suggested settings are as follows:
Name Default Value Suggested Value
KeepAlive time 7200000 (2 hours) Same
KeepAlive interval 1000 (1 second) 10000 (10 seconds)
TcpKeepCnt 120 (2 minutes) 240 (4 minutes)
TcpKeepTries 20 (20 re-tries) Same
TcpMaxConnectAttempts 3 6
TcpMaxConnectRetransmission 3 6
TcpMaxDataRetransmission 5 8
TcpMaxRetransmissionAttempts 7 10
If the registry value is not defined, create it.

Testing DB2 With The MTS "BANK" Sample Application

You can use the "BANK" sample program that is shipped with MTS to test the setup of the client products and MTS.

Follow these steps:

  1. Change the file \Program Files\Common Files\ODBC\Data Sources\MTSSamples.dsn so that it looks like this:
       [ODBC]
       DRIVER=IBM DB2 ODBC DRIVER
       UID=your_user_id
       PWD=your_password
       DSN=your_database_alias
       Description=MTS Samples
    

    where:

  2. Go to ODBC Administration in the Control Panel, select the System DSN tab, and then add the data source:
    1. Select IBM ODBC Driver, and then select Finish.
    2. When presented with the list of database aliases, choose the one that was specified previously.
    3. Select OK.
  3. Use DB2 CLP to connect to a DB2 database under the ID your_user_id, as above.
    1. Bind the db2cli.lst file:
         db2 bind @C:\sqllib\bnd\db2cli.lst blocking all grant public
      
    2. Bind the utilities.

      If the server is a DRDA host server, bind ddcsmvs.lst, ddcs400.lst, or ddcsvm.lst, depending on the host that you are connecting to (OS/390, AS/400, or VSE&VM). For example:

         db2 bind @C:\sqllib\bnd\@ddcsmvs.lst blocking all grant public
      

      Otherwise, bind the db2ubind.lst file:

         db2 bind @C:\sqllib\bnd\@db2ubind.lst blocking all grant public
      
    3. Create the sample table and data for the MTS sample application, as follows:
         db2 create table account (accountno int, balance int)
         db2 insert into account values(1, 1)
      
  4. On the DB2 client, ensure that the database manager configuration parameter tp_mon_name is set to MTS.
  5. Run the "BANK" application. Select the Account button and the Visual C++ option, then submit the request. Other options may use SQL that is specific to SQL Server, and may not work.


[ Top of Page | Previous Page | Next Page ]