# RazorSQL

## Query, Edit, Browse, and Manage Databases

- razorsql.com
- Contact

# DB2 Connection Help

RazorSQL ships with the IBM Universal Type 4 and Type 2 JDBC drivers, and supports connecting via the IBM ODBC drivers. Any other drivers mentioned below would need to be obtained manually.

There are several ways to connect to DB2, and the best way to connect depends on what type of DB2 installation you have. DB2 comes in many flavors, such as DB2 UDB for Linux, Unix, and Windows; DB2 UDB for OS/390 and z/OS; DB2 UDB for iSeries; and DB2 UDB for VSE and VM servers. See below for more information on connecting to each of these types of options.

DB2 UDB for Linux, Unix, and Windows
DB2 for OS/390 and z/OS
DB2 for iSeries and AS400

## DB2 UDB for Linux, Unix, and Windows

Connecting to DB2 via JDBC
Connecting to DB2 via ODBC

RazorSQL ships with the IBM DB2 Universal Type 4 JDBC Driver. This driver should work properly for most installations of DB2 UDB for Linux, Unix, and Windows. IBM also provides an ODBC driver with their runtime client installations for DB2. Depending on your configuration, it may be easier to connect via the ODBC driver. ODBC is available for Windows users only. If you have the IBM DB2 ODBC driver installed, you can connect with RazorSQL via ODBC as long as you have an ODBC data source for your DB2 instance configured on your machine. See the ODBC Setup page for information on how to configure an ODBC data source.

## Connecting to DB2 via JDBC

Users can connect to DB2 via JDBC in several ways. Since the IBM Universal Type 4 driver is the newest driver and also ships with RazorSQL, this driver is recommended. Other options include the IBM Universal Type 2 driver, the DB2 App driver, and the DB2 net driver.

IBM Universal Type 4 Driver

RazorSQL ships with the Universal Type 4 driver, so no additonal downloads are necessary to connect with this driver. The DB2 database server has to be configured to allow direct connections in order for this to work. This means that the DB2 server would need to be listening on a port that applications can connect to. For example, a common port DB2 listens on for this type of connection is 50000.

Assuming your DB2 instance is configured to allow this type of connection, you would need to provide RazorSQL with your login id and password, and the following information:
host: This would be the host name or ip address of your server
port: This is the port that DB2 is listening on. 50000 is usually the default.
database name: This is the name of the database to connect to.

IBM Universal Type 2 Driver

RazorSQL ships with the Universal Type 2 driver, so users can use the IBM Universal Type 2 Driver to connect to DB2 as long as there is a DB2Connect installation on their machine or on a Gateway. Since the type 2 driver uses DB2Connect, the only piece of information required to connect is the database name. The DB2Connect configuration needs to be complete for this option to work.

DB2 App Driver

The DB2 App driver is a legacy driver that can be used to connect to DB2 assuming that DB2 client software is installed on the user's machine. RazorSQL does not ship with this driver.

DB2 Net Driver

The DB2 Net driver is a legacy driver that can be used to make a direct connection to DB2 assuming that the appropriate proxy is set up on the DB2 server machine to listen for connections. RazorSQL does not ship with this driver.

## Connecting to DB2 via ODBC

If you have the IBM DB2 ODBC driver installed, you can connect with RazorSQL via ODBC as long as you have an ODBC data source for your DB2 instance configured on your machine. See the ODBC Setup page for information on how to configure an ODBC data source.

## DB2 UDB for OS/390 and z/OS

RazorSQL ships with the IBM DB2 UDB JDBC Universal driver. This driver does support access to DB2 running on z/OS. However, to connect to DB2 z/OS, a special license file is needed. The license file is contained in the DB2 Connect software installation.

Here is the name of the license file: db2jcc_license_cisuz.jar

Once the license file is obtained, to connect to DB2 on z/OS, you can go to the Connections -> Add Connection Profile, select DB2 as the database type, JDBC as the connection type, and enter the paths to the db2jcc_license_cisuz.jar and the db2jcc.jar file that ships with RazorSQL in the driver location field (the default location for this would be C:\Program Files\RazorSQL\drivers\db2\db2jcc.jar). Those two paths should be separated by a semi-colon. For a JDBC type 4 connection, the JDBC URL format would be the following:
jdbc:db2://<server hostname or IP address>:<DB2 UDB Instance port number>/<Database Name>
For example, jdbc:db2//127.0.0.1:446/SAMPLE
For a JDBC type 2 connection, (you would actually be connecting via DB2 Connect, so DB2 Connect needs to be installed and configured on your machine), the JDBC URL format would be the following:
jdbc:db2:<dbname>
For example, jdbc:db2:SAMPLE
The driver class for all of the above examples is the following:
com.ibm.db2.jcc.DB2Driver

For more information on connecting to DB2 via JDBC, please see the following: http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0401chong/

## DB2 UDB for iSeries and AS/400

RazorSQL can connect to iSeries via ODBC or JDBC. If you are on a Windows machine, the easiest way to connect is probably via ODBC. You would need to obtain the iSeries Access for Windows client from IBM and set up an ODBC datasource on your machine. RazorSQL can then use the datasource to connect to DB2. There is an open source JDBC driver available for AS400 / iSeries called jtopen. RazorSQL can use this driver to connect to DB2. More information on the driver is available from here:
http://jt400.sourceforge.net/
The IBM Type 4 Universal JDBC driver that ships with RazorSQL can also be used to connect to DB2 on iSeries. However, a special license file is required for this to work. The license file is included in the IBM DB2Connect installation. See the above section DB2 UDBC for OS/390 and z/OS for information on setting up the license file and configuring the type 4 connection.

## Additional Information

Connecting to DB2 can be a very complex process, especially for DB2 on non Linux/Unix/Windows systems such as iSeries, AS/400, OS/390 and z/OS. Lised below are links to more information about getting connected to DB2:

DB2 Connectivity Cheat Sheet for Application Developers
DB2 Connectivity Cheat Sheet

## Manual DB2 JDBC Information

If manually configuring your connection, see the following for JDBC driver class and JDBC URL format. JDBC Information