Discussion:
Using java 64bit with DB2 32bit instance
(too old to reply)
Juliana Grossi
2007-08-29 19:08:24 UTC
Permalink
I have a java application that has a connection to a DB2 instance using

Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();

I´m trying to upgrade this application to use java 5 64bit, so I have compiled the code using java 5 64bit installed in AIX 64bit environment. The DB2 instance is 32bit (v8.1 FP8) and cannot be migrated to a 64bit version. When I run the application, I get the following exception:

java.sql.SQLException: java.lang.UnsatisfiedLinkError: db2jdbc (No such file or directory)
at oem.edge.yldmgt.com.SimpleApplication.openConnection(SimpleApplication.java:351)

Note that if I use java 5 32bit to run it, I don´t get the error and if I remove the DB2 connection part from code, I don´t get the error either.

Does anybody know how I can use a 32bit DB2 instance successfully in a 64bit environment?

Thanks a lot!
A***@hcm.honda.com
2007-08-29 20:11:04 UTC
Permalink
Hi; this can be overcome by creating a 64-bit 'dummy' instance where you run your Java application and then connect to the 32-bit instance to get your data.
Juliana Grossi
2007-08-29 20:18:37 UTC
Permalink
How can I do that?
Juliana Grossi
2007-08-29 20:42:14 UTC
Permalink
Inside /<db2_instance_home>/sqllib there are 2 folders with DB2 libraries a /lib and a /lib64.
When I compile and run the application using /lib in LD_LIBRARY_PATH and LIBPATH, I get the exception I said before. When I compile and run the application using /lib64 in LD_LIBRARY_PATH and LIBPATH, I don´t get any exception but it gets stuck in a infinite loop inside Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance() method.

Any idea?
Knut Stolze
2007-08-29 22:06:10 UTC
Permalink
Post by Juliana Grossi
Inside /<db2_instance_home>/sqllib there are 2 folders with DB2 libraries
a /lib and a /lib64. When I compile and run the application using /lib in
LD_LIBRARY_PATH and LIBPATH, I get the exception I said before. When I
compile and run the application using /lib64 in LD_LIBRARY_PATH and
LIBPATH, I don´t get any exception but it gets stuck in a infinite loop
inside Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance()
method.
You cannot use 32bit libraries in a 64bit program (unless the program
actually provides for that). So you should use the 64-bit libraries that
DB2 provides, i.e. the libraries in the sqllib/lib64/ directory.
--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Ian
2007-08-30 22:50:24 UTC
Permalink
Post by Juliana Grossi
I have a java application that has a connection to a DB2 instance using
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
Alternatively, couldn't you use the Type-4 Universal driver?

Class.forName("com.ibm.db2.jcc.DB2Driver");

It doesn't depend on the native CLI layer, and therefore shouldn't
suffer from the same 32/64 bit issues. Right?
Juliana Grossi
2007-08-30 23:04:30 UTC
Permalink
You are right! That´s exactly what I did to solve the problem.

I used driver type 4 (com.ibm.db2.jcc.DB2Driver), that is pure java and doesn´t depend on OS environment.
Note you have to add db2jcc*.jar files in your classpath and change your connection string to jdbc:db2://<host>:<port>/<db_name> instead of jdbc:db2:<db_alias>
Continue reading on narkive:
Loading...