In this process, a transaction can only connect to one database. In the type2 connection, connect retains the connected database and connects to a new database. Such a transaction is called a distributed unit of work. The following describes the Two DB Connection Methods type1 and type2 provided by DB2.
DB2 provides two DB Connection Methods: type1 and type2:
In the type1 connection, connect will disconnect the connected database. One transaction can only connect to one database.
In the type2 connection, connect retains the connected database and connects to a new database. Such a transaction is called a distributed unit of work.
Both methods do not allow the AP to connect to a DB multiple times at the same time!
Below are some type2 experiments performed under CLP:
QUOTE:
$ Db2 list applications
Authorization identity Application name application identity DB proxy process
Handle name serial number
- DB2ADMIN db2dasstm.exe 10 *LOCAL.DB2.00A180010035 DWCTRLDB 1
- DB2ADMIN db2dasstm.exe 9 *LOCAL.DB2.00A180010034 DWCTRLDB 1
- DB2ADMIN db2dasstm.exe 8 *LOCAL.DB2.00A180010020 DWCTRLDB 1
- $ db2 connect to otherdb
Database connection information
Database Server = DB2/NT 8.1.2
SQL authorization id = DAVID
Local Database alias = OTHERDB
- $ db2 connect to sample
Database connection information
Database Server = DB2/NT 8.1.2
SQL authorization id = DAVID
Local Database alias = SAMPLE
- $ db2 list applications
Authorization identity Application name application identity DB proxy process
Handle name serial number
- DAVID db2bp.exe 22 *LOCAL.DB2.012480161735 SAMPLE 1
- DB2ADMIN db2dasstm.exe 10 *LOCAL.DB2.00A180010035 DWCTRLDB 1
- DB2ADMIN db2dasstm.exe 9 *LOCAL.DB2.00A180010034 DWCTRLDB 1
- DB2ADMIN db2dasstm.exe 8 *LOCAL.DB2.00A180010020 DWCTRLDB 1
- $ db2 set client connect 2
The DB20000I set client Command is successfully completed.
- $ db2 connect to otherdb
Database connection information
Database Server = DB2/NT 8.1.2
SQL authorization id = DAVID
Local Database alias = OTHERDB
- $ db2 list applications
Authorization identity Application name application identity DB proxy process
Handle name serial number
- DAVID db2bp.exe 23 *LOCAL.DB2.012480161849 OTHERDB 1
- DAVID db2bp.exe 22 *LOCAL.DB2.012480161735 SAMPLE 1
- DB2ADMIN db2dasstm.exe 10 *LOCAL.DB2.00A180010035 DWCTRLDB 1
- DB2ADMIN db2dasstm.exe 9 *LOCAL.DB2.00A180010034 DWCTRLDB 1
- DB2ADMIN db2dasstm.exe 8 *LOCAL.DB2.00A180010020 DWCTRLDB 1
The above test did not test transaction commit. If the test is to turn off the automatic commit of command option, you can test the connection and modification of multiple DBS in a transaction! In addition, there are three types of type2 connections: syncpoint onephase (default), syncpoint twophase, and syncpoint none.
Using type2 connection, you can open multiple connections in a command window, but the operation is only valid for the last connection. If you want to switch, you can use set connection. The above content is an introduction to the Two DB connection Methods type1 and type2 provided by DB2. I hope you will get some benefits.