Setting up IBM DB2 Connect Runtime Environment on Linux/Unix
Purpose
To connect to a DB2 Connect server which subsequently connects to the DB2 Database from a local Linux/Unix box.
Prerequisites
- A working installation of Linux or Unix.
- Download the runtime environment for your Linux/Unix system here
- A working DB2 Connect server.
- A DB2 Database to which the DB2 Connect Server will connect.
Setting Up Your Runtime Environment
This process takes working closely with the Database Administrator Group. They will set up the DB2 Connect Server and make sure all binds are done so that you can connect. You must know the server name and the port number on the DB2 Connect Server.
Install Runtime Environment
You must install as root. Once you have downloaded the runtime environment for your flavor of unix (above),
untar it, find and run the db2setup script. The installation wizard will walk you through
all of the steps required. NOTE: It is HIGHLY RECOMMENDED that you create a new userid
specifically to be used only for DB2 Connect -- this will be known as your DB2 Instance.
The DB2 Connect Server is: inyo.berkeley.edu and you should use port 50000.
This document assumes the DB2 database is ucbkdb2y (test). If you are using more than
one connection with the same database name, you can create an alias for each new database defined.
The DB2 Connect Runtime files are typically installed under /opt with a directory under the DB2 user's home directory called sqllib
linking to all necessary files in the installation.
Set Environment Variables
You will need to export the following environment variables for use with JDBC:
- export DB2INSTANCE=db2instance
- export LD_LIBRARY_PATH=/db2instance/sqllib/lib
You can either set these at the system (login level) or within eclipse (right-click on the java class | Run | Run As... | Environment tab, then enter the variables.
Running DB2 Connect
Log in as the DB2 User you created above. Make sure the installation path where DB2 Connect was installed
is in your path and get the db2 prompt by entering the command: db2.
Enter the following commands at the db2 prompt (NOTE: do not type "db2>"):
- db2> catalog tcpip node ipdb2y remote inyo server 50000
- db2> catalog database ucbkdb2y at node ipdb2y authentication server_encrypt
- db2> connect to ucbkdb2y user username using password
If you want to create a database alias, enter the following after cataloging the database:
- db2> catalog database ucbkdb2y as <<alias>> at node ipdb2y authentication server_encrypt
- db2> connect to <<alias>> user username using password
You should be connected and ready to execute sql commands (note: you will still be at the db2 prompt). To get out of the db2 prompt, enter terminate.


