Why am i not able to connect to DB2 from java on linux?

This may happen because you do not have the right environment variables set up on linux machine. The best pointer to this is that, when you are logged in as db2 unix user (note that in db2 database user is also an operating system user) you are able to connect to the database, but when you are logged in as some other user, it fails.

The environment variables that you need to set are:

export DB2DIR=/opt/ibmapps/db2/V9.0
export DB2INSTANCE=mydb2inst
export LD_LIBRARY_PATH=/home/mydb2inst/sqllib/lib32
export LOGNAME=mydb2inst
export PATH=/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:




You can see that these environment variables do exist when you login as the db2 unix user. This you can see by typing:

$ set


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: