Updating multiple databases in a transaction

If your data is distributed across multiple databases, you may want to read and update several databases in a single transaction. This type of database access is called a multisite update.

About this task

Figure 1. Updating multiple databases in a single transaction
Figure 1 shows a database client running a funds transfer application that accesses three database servers: one containing the checking account, another containing the savings account, and the third containing the banking fee schedule.

Procedure

To set up a funds transfer application for this environment, you have two options:

  • Using the Db2® transaction manager (TM):
    1. Create the necessary tables in the appropriate databases
    2. If physically remote, set up the database servers to use the appropriate communications protocols
    3. If physically remote, catalog the nodes and the databases to identify the databases on the database servers
    4. Precompile your application program to specify a type 2 connection (that is, specify CONNECT 2 on the PRECOMPILE command), and two-phase commit (that is, specify SYNCPOINT TWOPHASE on the PRECOMPILE command)
    5. Configure the Db2 transaction manager (TM).
  • Using an XA-compliant transaction manager:
    1. Create the necessary tables in the appropriate databases
    2. If physically remote, set up the database servers to use the appropriate communications protocols
    3. If physically remote, catalog the nodes and the databases to identify the databases on the database servers
    4. Precompile your application program to specify a type 2 connection (that is, specify CONNECT 2 on the PRECOMPILE command), and one-phase commit (that is, specify SYNCPOINT ONEPHASE on the PRECOMPILE command)
    5. Configure the XA-compliant transaction manager to use the Db2 databases.