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
2010-09-02 09:33:47
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
2010-09-02 09:37:55
What log level are you using? What log statement does it hang on?
Joel
2010-09-02 09:56:37
I just enabled the setLogWriter method for DriverManager. It takes time when it reaches the line with the method "getHostAddressFromIpAddr"
GPX
2010-09-02 10:16:50
What is your JDBC connection string?
Joel
2010-09-02 11:37:35
jdbc:db2j:net://host-ip-address:port/DBSID
GPX
2010-09-02 12:28:37
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
2010-09-02 09:56:32