I am trying to connect to an IBM DB2 9 database on a Linux server from my Java application. I am using db2jcc.jar
(DB2 Universal JDBC Driver).
Establishing a connection is taking a ridiculous amount of time. What could be wrong? I know there are a lot of factors that could cause this, but I want to get down to the root cause.
First off I would try to up the log level on the driver to debug or even trace. This might give you an easy way of seeing where it is hanging in it's attempt to complete the connection. Are you using log4j?
Establish tracing on the client and on the server side. This should allow you to differentiate between the following possible issues:
Once you have found the issue you'll have to dig deeper in order to understand why this is the case.
This is happening because the driver does a reverse lookup of the IP to resolve a host name, an easy fix is to add the server and hostname to your System32\drivers\etc\hosts (if you're on windows) file, then use the hostname you just mapped. E.g.
%WINDOWS%System32\drivers\etc\hosts
128.0.0.200 DB_SERVER
then in your application:
jdbc:db2://DB_SERVER:55701/SCHEMA_NAME
Check if your DNS configuration is 100% correct.