Connecting CLPPlus to a Db2 database
Command line processor plus (CLPPlus) provides a command-line interface that you can use to connect to the BLUDB database, and to define, edit, and run statements, scripts, and commands. CLPPlus is included in the Db2 driver package .
Before you begin
-
Verify prerequisites, including installing driver packages, configuring your local environment, and downloading SSL certificates (if needed)
-
Collect connect information, including database details such as host name and port numbers, and connect credentials such as user ID and password
-
The JAVA_HOME environment variable is set to the Java installation directory on your computer.
-
The PATH environment variable setting includes the bin subdirectory of the Java installation directory on your computer.
Procedure
Results
Example
The following examples use a short script that retrieves rows from the sample table GOSALES.BRANCH. The script file is named cities.sql and is on the local Windows computer in the C:\temp directory. The cities.sql file contains this text:
SET ECHO ON
SELECT branch_code, city from GOSALES.BRANCH;
Example 1: To run the script interactively:
- Start CLPPlus with your user ID and the alias that you created in the
db2dsdriver.cfg file:
clpplus user_id@alias
- Enter your password.
- At the SQL prompt, enter the following text:
start C:\temp\cities.sql
Example 2: Start CLPPlus with your user ID and the alias that you created in the db2dsdriver.cfg file and run the script in one step:
clpplus user_id/password@alias @C:\temp\cities.sql
Sample output from the cities.sql script follows:
BRANCH_CODE CITY
----------- --------------------------------------------------
6 Paris
7 Milano
9 Amsterdam
13 Hamburg
14 München
15 Kista
17 Calgary
18 Toronto
19 Boston
20 Seattle
21 Los Angeles
22 Miami
23 Lyon
24 Distrito Federal
25 Tokyo
26 Osaka City
28 Melbourne
29 Bilbao
30 Sao Paulo
31 Kuopio
32 Seoul
33 Singapore
BRANCH_CODE CITY
----------- --------------------------------------------------
34 Shanghai
35 London
36 Birmingham
37 Zürich
38 Heverlee
39 Wien
40 Geneve
29 rows were retrieved.