DB2 10.5 for Linux, UNIX, and Windows

Application process connection states

There are certain rules that apply to the execution of a CONNECT statement.

The following rules apply to the execution of a CONNECT statement:
  • A context cannot have more than one connection to the same application server at the same time.
  • When an application process executes a SET CONNECTION statement, the specified location name must be an existing connection in the set of connections for the application process.
  • When an application process executes a CONNECT statement, and the SQLRULES(STD) option is in effect, the specified server name must not be an existing connection in the set of connections for the application process. For a description of the SQLRULES option, see Options that govern unit of work semantics.

If an application process has a current connection, the application process is in the connected state. The CURRENT SERVER special register contains the name of the application server for the current connection. The application process can execute SQL statements that refer to objects managed by that application server.

An application process that is in the unconnected state enters the connected state when it successfully executes a CONNECT or a SET CONNECTION statement. If there is no connection, but SQL statements are issued, an implicit connect is made, provided the DB2DBDFT environment variable is set with the name of a default database.

If an application process does not have a current connection, the application process is in the unconnected state. The only SQL statements that can be executed are CONNECT, DISCONNECT ALL, DISCONNECT (specifying a database), SET CONNECTION, RELEASE, COMMIT, ROLLBACK, and local SET statements.

An application process in the connected state enters the unconnected state when its current connection intentionally ends, or when an SQL statement fails, causing a rollback operation at the application server and loss of the connection. Connections end intentionally following the successful execution of a DISCONNECT statement, or a COMMIT statement when the connection is in release-pending state. (If the DISCONNECT precompiler option is set to AUTOMATIC, all connections end. If it is set to CONDITIONAL, all connections that do not have open WITH HOLD cursors end.)