Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have installed DB2 10.1 in a Red hat box. During the installation I was asked to create several users (db2inst1, db2fenc1 etc). I have been using db2inst1 to perform all operations with DB2 and it works perfectly fine. The sqllib files are located in

/home/db2inst1/sqllib

The installation files are located in

/opt/ibm/db2/V10.1/

All users have access to both these folders. I now want to perform the DB2 operations with another user, namely "john". Given that db2 uses the underlying user/password of the host machine, I added the groups dasadm1 and ds2iadm1 to the "john" user (which are the ones listed in db2inst1).

uid=500(john) gid=500(john) groups=500(john),101(dasadm1),102(db2iadm1)

I can properly enter the db2 cmd with the user "john"

[john@rhel6 java]$ /home/db2inst1/sqllib/bin/db2

but when I run my java app as user "john" I get the following error:

SQLException: com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][4.13.127] Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError: db2jcct2 (Not found in java.library.path): ERRORCODE=-4472, SQLSTATE=null

this error does not appear if I run the same java app as user db2inst1. The library paths are the exactly the same for both users. Any idea what is going wrong?

share|improve this question

migrated from stackoverflow.com Jan 3 '13 at 4:38

This question came from our site for professional and enthusiast programmers.

2  
Adding users to the default groups db2iadm1 and dasadm1 will provide elevated (SYSADM) privileges – you probably do not want to do that unless the user account is for a DBA. Grant general user access either directly to the user IDs or using either operating system groups or database roles. –  Ian Bjorhovde Jan 4 '13 at 0:04

2 Answers 2

up vote 3 down vote accepted

My gut feeling is that you did not update user "john's" profile to invoke the DB2 profile setup. If you do not do this, then you won't have "access" to DB2 per say, even though the binaries are there.

So what you want to do is write a script that checks for your DB2 instance "home" profile script in your case it would be /home/db2inst1/sqllib/db2profile and if it is there, to invoke it.

if [ -f /home/db2inst1/sqllib/db2profile ] ; then
     . /home/db2inst1/sqllib/db2profile
     if [ ! $? = 0 ] ; then
          echo "Error setting up DB2 instance access"
     else
          echo "DB2 instance access set up"
     fi
fi
share|improve this answer
    
This solution will resolve both the command line and Java issues because it sets up both the DB2 command-line environment and the CLASSPATH. –  Ian Bjorhovde Jan 4 '13 at 0:05
    
How do I invoke the DB2 profile setup? Moreover, when I run your script it returns the latter: ""DB2 instance access set up" –  John Pappas Jan 9 '13 at 14:08
    
@JohnPappas - Right. Now that you have DB2 instance access, you should be able to invoke it on the command line by just typing db2. (Meaning you wont' have to browse into instance directory to call DB2 functionality.). –  Chris Aldrich Jan 9 '13 at 15:00
    
[john@rhel ~]$ ./test.sh DB2 instance access set up [john@rhel ~]$ db2 Command not found. –  John Pappas Jan 9 '13 at 16:49
    
but [john@rhel ~]$ /home/db2inst1/sqllib/bin/db2 (c) Copyright IBM Corporation 1993,2007 Command Line Processor for DB2 Client 10.1.0 ...... Yet this does not solve my problem in regards to the SQLException. –  John Pappas Jan 9 '13 at 16:50

You are missing the db2 drivers on the classpath for the java app.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.