Extremely slow DB2 connectivity in Java

2019-05-23 08:45发布

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.

4条回答
唯我独甜
2楼-- · 2019-05-23 08:59

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?

查看更多
We Are One
3楼-- · 2019-05-23 09:00

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.

查看更多
地球回转人心会变
4楼-- · 2019-05-23 09:05

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

查看更多
再贱就再见
5楼-- · 2019-05-23 09:07

Check if your DNS configuration is 100% correct.

查看更多
登录 后发表回答