CONNECT CLPPlus command

The CONNECT CLPPlus command changes the user ID connected to a database, connects to a different database, or does both. The command also displays the result of the change.

Invocation

This command must be run from the CLPPlus interface.

Authorization

None

Required connection

None

Command syntax

Read syntax diagramSkip visual syntax diagramCONNECTconnection_identifier/using (clientApplcompat clientApplcompat-str; currentPackageSet currentPackageSet-str; authentication authentication-str; securityTransportMode SSL; sslCertLocation sslCertLocation-str); apikey apikey-str; accesstoken accesstoken-str; accesstokentype accesstokentype-str@dsn_alias
connection_identifier
Read syntax diagramSkip visual syntax diagramuser /password@hostname@variable:port/database
dsn_alias
Read syntax diagramSkip visual syntax diagram @ dsn_alias using (clientApplcompat clientApplcompat-str; currentPackageSet currentPackageSet-str; apikey apikey-str; accesstoken accesstoken-str; accesstokentype accesstokentype-str

Command parameters

Do not include spaces between any of the parameters.
Note: The ACCESSTOKEN and accesstokentype options are available starting from Db2® version 11.5.4.
ACCESSTOKEN accesstoken-str
Identifies the token used for authentication at the server. Specifying an access token is only valid if the negotiated authentication type for the connection is TOKEN or GSSAPI. If the negotiated authentication type is TOKEN, then accesstokentype must also be specified.
accesstokentype accesstokentype-str
Specifies the type of access token. Must be a token type supported by the server. The ACCESSTOKENTYPE is mandatory when using TOKEN authentication, but is optional for GSSPLUGIN.
APIKEY apikey-str
Identifies the API key used for authentication at the server. An APIKEY can only be specified when the negotiated authentication type for the connection is GSSPLUGIN (SQLSTATE 08001).
user
Specifies the user ID to connect to the database.
password
Specifies the password that corresponds to the user ID.
hostname
Specifies the name of the computer on which the database is located. For example, for a computer that is named ascender, specify @ascender.
variable
Specifies the name of a variable, which contains CLPPlus related information. This variable can define connection string type information and must be defined in a file that is called login.sql, which is read by the CLPPlus interface during start-up. login.sql is read from following locations:
  • Loc-1: login.sql is configurable using environment variable CLPPLUS_USER_STARTUP_SCRIPT. For example, define in an environment variable as <CLPPLUS_USER_STARTUP_SCRIPT=C:\conf\login.sql>
  • Loc-2: Configure login.sql in the home directory of a client machine to launch directory.
  • Loc-3: Configure login.sql in the current directory. Clpplus is launched from the current directory.

If login.sql is configured using all three locations in the client machine then Loc-1 is of highest precedence to apply in clpplus. Order of precedence from highest to lowest for applying in clpplus is Loc-1>Loc-2>Loc-3.

port
Specifies the port number that receives connections on the computer where the database server is installed. The default is 50000.
database
Specifies the database name to which the connection is made. The default is SAMPLE.
/
Specifies the current operating system login user ID is used to connect to the database.
dsn_alias
Specifies the database connection information is read from the IBM® data server driver configuration file (db2dsdriver.cfg) with alias name dsn_alias. If dsn_alias is not found in the IBM data server driver configuration file, the string dsn_alias is used as a database name and all other connection parameters are obtained interactively. If you configure an LDAP directory server in the specified IBM data server driver configuration file, the following steps apply:
  1. The database connection information is read from the DSN entry with alias name dsn_alias in the IBM data server driver configuration file.
  2. If dsn_alias is not found in the IBM data server driver configuration file, the configured LDAP Directory server is searched for an entry with the name dsn_alias.
  3. If dsn_alias is not found on the LDAP Directory server, dsn_alias is used as a database name and all other connection parameters are obtained interactively.
Note: CLPPlus supports connection attempts to databases with DSN aliases and the authentication mechanism that is defined in the IBM data server driver configuration. If you do not define an authentication mechanism in the IBM data server driver configuration file, a default authentication mechanism is used by CLPPlus. The default authentication mechanism is equivalent to that of JCC.
clientApplompat
For connections to Db2 for z/OS 12.0 with data servers at a function level of V12R1M501 or later, set the capabilities of a particular instance of the IBM Data Server Driver for JDBC and SQLJ to a function level that is less than or equal to the function level of the data server. This is optional when using ().
currentPackageSet
The currentPackageSet identifies the collection ID to search for necessary packages when executing test cases using clpplus. This is optional when using ().
Authentication
This parameter is used to specify the authentication type the user wants when connecting using clpplus session. This is optional when using ().
securityTransportMode
This parameter is used to specify value "SSL". This will set the SSL connection to true when the user wants to use SSL when connecting using clpplus session. This is optional when using ().
sslCertLocation
This parameter is used to specify certificate location when the user wants to use SSL when connecting using surplus session. This is optional when using (). securityTransportMode and sslCertLocation need to specify together in order to connect using SSL connection.

Examples

In the following example, the database connection is changed to database Db2 on the local host at port 5445 with user name smith:

SQL> CONNECT smith/mypassword@localhost:5445/db2
Connected to CLPlus 1.1.0.10 (localhost:5445/db2) AS smith

In the same session, the connection is changed to the user name CLPPlus. For this connection, localhost, 5444, and Db2 are maintained as the host, port, and database values.

SQL> CONNECT CLPPlus/password
Connected to CLPPlus 1.1.0.10 (localhost:5444/db2) AS CLPPlus
The following example attempts to connect to a database by first locating an IBM data server driver configuration file. If one is found, the default_dsn is read for the host, port, and database values. The current logon ID is used in the connection attempt. If no IBM data server driver configuration file is found, all required parameters are requested interactively.
SQL> CONNECT /
The following example attempts to connect to a database by fetching the parameters from the data_dsn alias in the IBM data server driver configuration file. The db2admin user ID is used in the connection. Any parameters that cannot be read are requested interactively.
SQL> CONNECT db2admin@data_dsn
In the following example, the login.sql file contains a variable definition that is used to attempt a connection to a database. The login.sql file contains define connStr = localhost:50000/sample and can be used in the CONNECT CLPPlus command as follows:
SQL> CONNECT db2admin@connStr
A connection by the db2admin user is attempted on the sample database on the localhost, which has a listener port number of 50000.