2

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?

1
  • 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. Jan 4, 2013 at 0:04

2 Answers 2

5

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
6
  • This solution will resolve both the command line and Java issues because it sets up both the DB2 command-line environment and the CLASSPATH. Jan 4, 2013 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" Jan 9, 2013 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.). Jan 9, 2013 at 15:00
  • [john@rhel ~]$ ./test.sh DB2 instance access set up [john@rhel ~]$ db2 Command not found. Jan 9, 2013 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. Jan 9, 2013 at 16:50
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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