Friday, January 28, 2011

Is the IBM DB2 UDB service not running? Can't make JDBC Type 4 connections

Keywords:
IBM DB2 v8 UDB Universal Driver TCP/IP which port windows service JDBC Type 4

Problem:
Attempting to make a JDBC Type 4 connection (ie pure java talking TCP/IP, no native code) to the DB2 server gives me:

com.ibm.db2.jcc.b.SqlException: IO Exception opening socket to server <myservername> on port 50000.
The DB2 Server may be down.


The DB2 server (running on Windows) is definitely running. In DB2 "Control Center" the "instance" ("DB2" the default name?) is definitely started. Looking at the local TCP ports being listened via netstat -abno there's no 50000 or anything close. So either the service that accepts the Type-4 JDBC connections (UDB) is not running or it's listening on a different port. How do you check?

Solution:
I couldn't find any mention of this in searching (though I did find "DB2 Version 8 Connectivity Cheat Sheet" which is good reference for DB2 generally), but by accident I stumbled on "Setup communications..." on right clicking the "DB2" instance in DB2 Control Center. From here the rest is straight forward:

  1. so, right click the "DB2" instance and select "Setup communications..."

  2. check TCP/IP

  3. click the Properties button and then just click the Default button to get default values

    • Note the port number: 50000 by default

  4. after clicking OK from the Properties and the communications dialog you'll have to restart the instance

    • right click the "DB2" instance and select Stop and then Start



Now when you check the open ports via netstat -abno you should hopefully see:

TCP 0.0.0.0:50000 0.0.0.0:0 LISTENING 3012
[db2syscs.exe]


To recap the IBM DB2 Universal Driver Type 4 (thin) connection details:
Driver Class:com.ibm.db2.jcc.DB2Driver
URL:jdbc:db2://<host>[:<port>]/<database_name>
eg:jdbc:db2://myservername:50000/MYDATABASE
Driver Class:com.ibm.db2.jcc.DB2Driver
Jar file(s):db2jcc.jar & db2jcc_license_cu.jar

No comments: