How to specify the connection type

Every IBM® RDBMS supports both type 1 and type 2 connection type semantics, in which only one transaction is active at any time.

In SQL, CONNECT (type 1) lets the application connect to only a single database at any time so a single transaction is active on the current connection. This connection type models DRDA remote unit of work processing.

Conversely, CONNECT (type 2), in SQL, lets the application connect concurrently to any number of database servers, all of which participate in a single transaction. This connection type models DRDA distributed unit of work processing.

Db2 ODBC supports both these connection types, but all connections in your application must use only one connection type at a given time. You must free all current connection handles before you change the connection type.

Important: Establish a connection type before you issue SQLConnect().

You can establish the connection type with either of the following methods:
  • Specify CONNECTTYPE=1 (for CONNECT (type 1)) or CONNECTTYPE=2 (for CONNECT (type 2)) in the common section of the initialization file.
  • Invoke SQLSetConnectAttr() with the Attribute argument set to SQL_ATTR_CONNECTTYPE andValuePtr set to SQL_CONCURRENT_TRANS (for CONNECT (type 1)) or SQL_COORDINATED_TRANS (for CONNECT (type 2)).