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:
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. | There are no rules about the connectable state. More than one CONNECT statement can be executed within the same unit of work. |
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 will succeed if the application group is the connectable state. | A CONNECT to an existing SQL connection of the activation group is an error. Thus, a CONNECT to the current server is an error. |
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.
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 work105:
If a CONNECT (Type 2) is performed to an application server that supports distributed unit of work:
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.