Description of the Two DB connection modes provided by the DB2 database

Source: Internet
Author: User

This article mainly tells you about the two DB connection methods provided by the DB2 database: type1 and type2. In the type1 connection, connect will disconnect the connected DB2, 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.

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:

 
 
  1. QUOTE:  
  2. $ db2 list applications  

Authorization identity Application name application identity DB proxy process

Handle name serial number

 
 
  1. DB2ADMIN db2dasstm.exe 10 *LOCAL.DB2.00A180010035 DWCTRLDB 1   
  2. DB2ADMIN db2dasstm.exe 9 *LOCAL.DB2.00A180010034 DWCTRLDB 1   
  3. DB2ADMIN db2dasstm.exe 8 *LOCAL.DB2.00A180010020 DWCTRLDB 1   
  4. $ db2 connect to otherdb  

Database connection information

Database Server = DB2 database/NT 8.1.2

SQL authorization id = DAVID

Local Database alias = OTHERDB

 
 
  1. $ 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

 
 
  1. DAVID db2bp.exe 22 *LOCAL.DB2.012480161735 SAMPLE 1   
  2. DB2ADMIN db2dasstm.exe 10 *LOCAL.DB2.00A180010035 DWCTRLDB 1   
  3. DB2ADMIN db2dasstm.exe 9 *LOCAL.DB2.00A180010034 DWCTRLDB 1   
  4. DB2ADMIN db2dasstm.exe 8 *LOCAL.DB2.00A180010020 DWCTRLDB 1   
  5. $ db2 set client connect 2  

The DB20000I set client Command is successfully completed.

 
 
  1. $ db2 connect to otherdb 

Database connection information

Database Server = DB2/NT 8.1.2

SQL authorization id = DAVID

Local Database alias = OTHERDB

 
 
  1. $ db2 list applications 

Authorization identity Application name application identity DB proxy process

Handle name serial number

 
 
  1. DAVID db2bp.exe 23 *LOCAL.DB2.012480161849 OTHERDB 1   
  2. DAVID db2bp.exe 22 *LOCAL.DB2.012480161735 SAMPLE 1   
  3. DB2ADMIN db2dasstm.exe 10 *LOCAL.DB2.00A180010035 DWCTRLDB 1   
  4. DB2ADMIN db2dasstm.exe 9 *LOCAL.DB2.00A180010034 DWCTRLDB 1   
  5. 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 DB databases 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;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.