Questions ‘n’ Answers – Technology

Just another WordPress.com weblog

Archive for the ‘DB2’ Category

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

Posted by qnaguru on August 14, 2008

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:

/usr/sbin:/usr/bin:/root/bin:/usr/local/JDK1.5.0_12/bin:/home/mydb2inst/sqllib/bin:

/home/mydb2inst/sqllib/adm:/home/mydb2inst/sqllib/misc

 

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

$ set

Posted in DB2, Java, Linux | Tagged: , , | Leave a Comment »