DB2 JDBC Driver and URL Information


Listed below are connection examples for three common JDBC drivers for IBM DB2:

IBM DB2 Universal Driver Type 4


DRIVER CLASS: com.ibm.db2.jcc.DB2Driver

DRIVER LOCATION: db2jcc.jar and db2jcc_license_cu.jar
(Both of these jars must be included)

JDBC URL FORMAT: jdbc:db2://<host>[:<port>]/<database_name>

JDBC URL Examples:

jdbc:db2://127.0.0.1:50000/SAMPLE


IBM DB2 Universal Driver Type 2


DRIVER CLASS: com.ibm.db2.jcc.DB2Driver

DRIVER LOCATION: db2jcc.jar and db2jcc_license_cu.jar
(Both of these jars must be included)

JDBC URL FORMAT: jdbc:db2:<database_name>

JDBC URL Examples:

jdbc:db2:sample


App JDBC Driver


In order to be able to use the DB2 App driver, certain software must be installed on your machine. This usually entails installing the IBM DB2 Client software. See IBM's site for more information.

DRIVER CLASS: COM.ibm.db2.jdbc.app.DB2Driver

DRIVER LOCATION: To use the App driver, the DB2 client software should be installed on your machine. The name of the file that contains the DB2 App driver is usually db2java.zip. However, this may change depending on the version of the client software that is installed. Usually, the DB2 client software is installed in the SQLLIB directory. For example, if you are using Windows, the following may be the location of the db2java.zip file: c:\SQLLIB\java12\db2java.zip

JDBC URL FORMAT: jdbc:db2:<database_name>

JDBC URL Examples:

jdbc:db2:test


Net JDBC Driver


DRIVER CLASS: COM.ibm.db2.jdbc.net.DB2Driver

DRIVER LOCATION: The DB2 Net drivers can be obtained by installing the DB2 client software from IBM. Depending on the version of the client software, the net drivers are usually contained in the db2java.zip file. For example, if using Windows, the following may be the location of the db2java.zip file that contains the drivers: c:\SQLLIB\java12\db2java.zip

JDBC URL FORMAT: jdbc:db2://<host>:<port>/<database_name>

The default port for IBM DB2 is many times one of the following: 446, 6789, or 50000. Usually, if the default port is being used by the database server, the :<port> value of the JDBC url can be omitted.

JDBC URL Examples:

jdbc:db2://neptune.acme.com:6789/test

jdbc:db2://127.0.0.1:6789/test