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
Command parameters
Do not include spaces between any of the parameters.
- 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.
- 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:
- The database connection information is read from the DSN entry with alias name dsn_alias in the IBM data server driver configuration file.
- 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.
- 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.
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.