Connecting to a DB2 database from Altair SLC on Windows
Ian Balanzá-Davis
Altair Employee
If you have data stored in a DB2 database, you can connect using the IBM Data Server Runtime Client. To install the client, you need to:
- Download the IBM Data Server Runtime Client from the Download Clients and Drivers page of the IBM website.
Make sure you select the correct connector to match the 64-bit Altair SLC installation. - On the same device as Altair SLC is installed, run the DB2 installer.
- Set the environment variable DB2CMDEXE to point to the db2cmd.exe file (typically under C:\Program Files\IBM\SQLLIB\BIN\db2cmd.exe), as follows:
- In the Control Panel, select the System and Security group. Select System and click Advanced System Settings.
- In the Advanced tab, click Environment Variables. In the System variables section, click New.
- Create a system variable with a Variable name of DB2CMDEXE, and a Variable value of the IBM Data Server Runtime Client installation path, for example C:\Program Files\IBM\SQLLIB\BIN\db2cmd.exe.
- Click OK to save the changes, and close the remaining system and security dialogs by clicking OK each time.
- Configure the connection to the server that you access:
- Open a command prompt and run DB2CMD. In the new window, type DB2 to access the command line processor for the DB2 client.
- Create a node to reference the remote database, using the following command:
catalog TCPIP node node_name REMOTE server SERVER port_service
Where:
- node_name is the local connection name.
- server is the IP address or name of the server hosting the database.
- port_service is either the server port number or the database instance name on the server.
- Create a database instance reference that you connect to through the node_name, using the following command:
catalog database database_name AS alias_name AT NODE node_name
Where:
- database_name is the instance of the database on the DB2 server.
- alias_name is the name you will use in the DB2 client to connect to the database instance.
- node_name is the previously-created connection name.
- Connect to a local connection name node_name using the following command:
connect to node_name user user-name using password
Where:
- node_name is the previously-created connection name.
- user_name and password are your user ID and password for the DB2 server.
If the connection is successful, the database information is displayed and you can close the command line for the DB2 client:
Database Connection Information
Database server = DB2/LINUX
SQL authorization ID = TEST
Local database alias = TESTDB2
Once the client has been installed, you can test the connection using the following SAS language program:
LIBNAME DATASRC DB2 user=user_name password=password DSN=TESTDB2;
PROC DATASETS LIBRARY=DATASRC;
RUN;
- Where you should replace user_name and password with your user name and password for the server.
- The DATASETS procedure returns the names of all tables in the selected database; for databases with large numbers of tables, this program might take some time to run.
0