Application servers

An activation group must be connected to the application server of a database manager before SQL statements can be executed.

A connection is an association between an activation group and a local or remote application server. A connection is also known as a session or an SQL session. Connections are managed by the application. The CONNECT statement can be used to establish a connection to an application server and make that application server the current server of the activation group.

An implicit CONNECT operation may also establish a connection to the application server:
  • An implicit CONNECT operation may occur when invoking a program, service program, or the STRSQL command. The application server is determined by the RDB parameter on the CRTSQLxxx and STRSQL commands.

    In these cases, the implicit CONNECT operation will not occur if an implicit or explicit CONNECT operation has already successfully or unsuccessfully occurred in the activation group. Thus, an activation group cannot be implicitly connected to an application server more than once.

  • An implicit CONNECT operation may occur when using a three-part object name or an alias that is defined to reference a three-part name of a table or view.
    In these cases, an implicit CONNECT operation is only allowed if all the objects referenced in the SQL statement refer to the same relational database. The only exceptions are:
    • The target table of an INSERT statement may be in one relational database and the tables referenced in the select-statement of the INSERT may be in another relational database.
    • The new table for a CREATE TABLE or DECLARE GLOBAL TEMPORARY TABLE statement may be in one relational database and the tables referenced in the select-statement may be in another relational database.

    The implicit CONNECT changes the current server for the statement. At the end of the statement the connection is set back to the prior current server.

  • When creating three-part qualified SQL stored procedures or SQL functions, objects in the procedure body must exist on both the DRDA client and DRDA server. If the procedure body objects do not exist, object not found errors may be signalled.

An application server can be local to, or remote from, the environment where the activation group is started. (An application server is present, even when distributed relational databases are not used.) This environment includes a local directory that describes the application servers that can be identified in a CONNECT statement. For more information about the directory, see the relational database folders in System i Navigator or the directory commands (ADDRDBDIRE, CHGRDBDIRE, DSPRDBDIRE, RMVRDBDIRE, and WRKRDBDIRE) in the following IBM® i Information Center topics:

To execute a static SQL statement that references tables or views, an application server uses the bound form of the statement. This bound statement is taken from a package that the database manager previously created through a bind operation. The appropriate package is determined by the combination of:

  • The name of the package specified by the SQLPKG parameter on the CRTSQLxxx commands. See Embedded SQL Programming for a description of the CRTSQLxxx commands.
  • The internal consistency token that makes certain the package and program were created from the same source at the same time.

A Db2® relational database product may support a feature that is not supported by the version of the Db2 product that is connecting to the application server. Some of these features are product-specific, and some are shared by more than one product.

For the most part, an application can use the statements and clauses that are supported by the database manager of the application server to which it is currently connected, even though that application is running via the application requester of a database manager that does not support some of those statements and clauses. Restrictions are listed in Characteristics of SQL statements.