CONNECT (Type 1) and CONNECT (Type 2) differences

There are two types of CONNECT statements.

They have the same syntax, but they have different semantics:

The following table summarizes the differences between CONNECT (Type 1) and CONNECT (Type 2) rules:

Table 1. CONNECT (Type 1) and CONNECT (Type 2) Differences
Type 1 Rules Type 2 Rules
CONNECT statements can only be executed when the activation group is in the connectable state. No more than one CONNECT statement can be executed within the same unit of work. More than one CONNECT statement can be executed within the same unit of work. There are no rules about the connectable state.
If the CONNECT statement fails because the server name is not listed in the local directory, the connection state of the activation group is unchanged.

If a CONNECT statement fails because the activation group is not in the connectable state, the SQL connection status of the activation group is unchanged.

If a CONNECT statement fails for any other reason, the activation group is placed in the unconnected state.

If a CONNECT statement fails, the current SQL connection is unchanged and any subsequent SQL statements are executed by the current server.
CONNECT ends all existing connections of the activation group. Accordingly, CONNECT also closes any open cursors for that activation group. CONNECT does not end connections and does not close cursors.
A CONNECT to the current server is executed like any other CONNECT (Type 1) statement. A CONNECT to the current server causes an error.

Determining the CONNECT rules that apply

A program preparation option is used to specify the type of CONNECT that will be performed by a program. The program preparation option is specified using the RDBCNNMTH parameter on the CRTSQLxxx command.

Connecting to servers that only support remote unit of work

CONNECT (Type 2) connections to application servers that only support remote unit of work might result in connections that are read-only.

If a CONNECT (Type 2) is performed to an application server that only supports remote unit of work:

  • The connection allows read-only operations if, at the time of the connect, there are any dormant connections that allow updates. In this case, the connection does not allow updates.
  • Otherwise, the connection allows updates.

If a CONNECT (Type 2) is performed to an application server that supports distributed unit of work:

  • The connection allows read-only operations when there are dormant connections that allow updates to application servers that only support remote unit of work. In this case, the connection allows updates as soon as the dormant connection is ended.
  • Otherwise, the connection allows updates.
1 DB2® for i using the initial DRDA support for native TCP/IP is an example of an application server that supports only remote unit of work.