Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQLException: DB2 Driver error allocating environment handle, rc = -1

130 views
Skip to first unread message

mary

unread,
Aug 14, 2000, 3:00:00 AM8/14/00
to
I have a problem running some JDBC code within a Servlet on AIX. I can run a
stand-alone JDBC program, but when I try and use JDBC through this servlet,
I get the following exception. Can anyone suggest any remedies and/or
possible causes (I couldn't find any documentation referring to the error
message - does anyone know where this should be??)?

"SQLException: DB2 Driver error allocating environment handle, rc = -1"

Thanks in advance,
Tushar.

Randall Parker

unread,
Aug 16, 2000, 3:00:00 AM8/16/00
to
It would help if you showed what piece of code and what exact call
resulted in the error. It is hard to guess otherwise...

On Mon, 14 Aug 2000 18:51:28 +0100 esteemed mary did'st hold forth
thusly:

Gary Murphy

unread,
Aug 17, 2000, 3:00:00 AM8/17/00
to
 
Tushar, I am getting the same error with DB2 UDB 6.1 and Linux.   When I run under root, the problem goes away, so it is a file permissions problem of some sort.  The following simplest case example will illustrate the failure.

 try
  {
  Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
  Connection c = DriverManager.getConnection("jdbc:db2:ukeygen","root","******");
  }
 catch(Exception e) { e.printStackTrace(); }

This ran from the scrapbook in VisualAge for Java.  As I mentioned, if I start VAJ as root this code works but that obviously isn't a valid solution.

My install was pretty "vanilla".  I took defaults to everything I could.
 

-- 
Gary Murphy
Hilbert Computing, Inc.
13632 S. Sycamore Dr.
Olathe, KS 66062
913-780-5051
 

Randall Parker

unread,
Aug 17, 2000, 3:00:00 AM8/17/00
to
Gary,

Do you get this problem if you use the net driver?

What that might tell you is whether it is not allowed to load the
db2java.zip vs not being allowed to access some file(s) in the app client
driver.

Also, do you have to actually connect as root? Or do you have to have
your current Linux login terminal session as root?

On Thu, 17 Aug 2000 09:30:56 -0500 esteemed Gary Murphy did'st hold forth
thusly:
>

Gary Murphy

unread,
Aug 17, 2000, 3:00:00 AM8/17/00
to
 
I'm not sure what you mean by the "net driver".   If there is a Type 3 or 4 for DB2, I would be interested in getting that code.  If there is another driver, let me know what zip/jar I am looking for and I will certainly try it out.   I am testing inside VisualAge for Java so all of the code is inside the repository (ivj.dat) so there shouldn't be a filesystem permissions issue on the class files for the driver.    When it fails, I am starting VAJ under my userid.  If I '/bin/su' to root and start VisualAge, it works OK.

The userid with which I connect to the database doesn't matter.  In fact, "root" doesn't have any grant on any tables.  I tried it again with the userid that does have access to the data (glm) and it fails the same way.  It is failing on the driver load.   I also checked to ensure that the failing userid (glm) has write access to /tmp in case DB2 is creating a FIFO or something.  I do have write access to /tmp.   I wonder if DB2 is creating a FIFO or something that only root has access to create.  I am able to connect via the 'db2' CLI, so it must be something specific to the JDBC driver, not DB2 in general.  I guess it could be execute access on the shared library (db2jdbc) or something like that.  Let me check that.  If I had the source code, I could likely figure it out myself.  <Sigh>.

Thank you for the help.
 
 

-- 
Gary Murphy
Hilbert Computing, Inc.
13632 S. Sycamore Dr.
Olathe, KS 66062
913-780-5051
 

Gary Murphy

unread,
Aug 17, 2000, 3:00:00 AM8/17/00
to
 
I found the net driver by reading another one of your posts.  That throws a "No Suitable Driver" exception.  I also checked the permissions on the shared object 'libdb2jdbc' and it is 666, so I should have execute permission on it.  I looked at the code in my libpath (in /usr/IBMdb2/V6.1/lib), but not the code that is owned by the 'db2inst' user.  Do you know when code is being loaded by DB2?  That may be another possibility.

Randall Parker

unread,
Aug 18, 2000, 3:00:00 AM8/18/00
to
No suitable driver, eh? Sounds like you have a pathing problem in VAJ.

However, I can't see how that problem would happen only for a particular
user id.

Have you imported all the classes from db2java.zip into the VAJ IDE? If
so, have you added them to the path of your project? If you right click
on the particular class that you are starting you can bring up properties
for that class that include pathing info to use to run the class. You
might need to fix that to include the project that you've imported
db2java.zip into.

An alternative is to add db2java.zip to the path for external jar and zip
files for VAJ. I forget the place where that is done and don't have VAJ
running at the moment to check.

BTW, If you use the net driver then you need to go run db2jstrt (it
starts db2jd daemon that the net driver connects to) and specify a port
number and then use that same port number when you pass a URL to the net
driver. I think the details will be found in the Command Reference.

Here's another thought: You need to use the right version of the JDBC
drivers. In VAJ 3.0 unless you are using the EAE version you are running
on a JVM 1.1.x level. Well, it can't handle using the JDBC 2.0 drivers
for JVM 1.2.x and later.

You also might want to check the Problems tab of your work space to see
if you have errors in the imported db2java.zip (which you likely would
have if you imported the wrong one).

There is also news.software.ibm.com which has VAJ news groups. Someone
there might have a guess as to what you might be doing wrong.

On Thu, 17 Aug 2000 14:59:27 -0500 esteemed Gary Murphy did'st hold forth
thusly:

0 new messages