views:

46

answers:

3

I am trying to connect to a IBM DB2 9 database on a Linux server from my Java application. I am using db2jcc.jar (DB2 Universal JDBC Driver). Establishing a connection takes a ridiculous amount of time? What could be wrong? I know there a lot of factors that could cause this, but I am willing to get down to the root cause. Please help me!

+1  A: 

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?

Joel
I am not using log4j. But I guess I can use the JDBC trace. And by hanging if you mean it just freezes, no - it doesn't. It does connect eventually. But every single time, it takes 20 seconds (consistently!) to do that!
GPX
What log level are you using? What log statement does it hang on?
Joel
I just enabled the setLogWriter method for DriverManager. It takes time when it reaches the line with the method "getHostAddressFromIpAddr"
GPX
What is your JDBC connection string?
Joel
jdbc:db2j:net://host-ip-address:port/DBSID
GPX
A: 

Establish tracing on the client and on the server side. This should allow you to differentiate between the following possible issues:

  • the driver implementation being slow (receives answer, but takes a long time to reply)
  • the network being slow (turnaround on both ends is fast, but with large breaks in between)
  • the database being slow to react (same as the first but on the server end)
  • there is just a lot of stuff going back and forth

Once you have found the issue you'll have to dig deeper in order to understand why this is the case.

Jens Schauder
A: 

Check if your DNS configuration is 100% correct.

Thorbjørn Ravn Andersen
Can you please tell me how, exactly?
GPX