How to get DB2 driver load correctly on AIX 5.3
I am having this annoying problem of loading DB2 driver from a JAVA application on AIX5.3, what I got is this :
java.sql.SQLException: java.lang.UnsatisfiedLinkError: db2jdbc (A file or directory in the path name does not exist.) at COM.ibm.db2.jdbc.app.DB2Driver.(Unknown Source) at java.lang.Class.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1243) at com.hp.sm.doctor.collection.commandLineConsole.CommandLineEntryMain.main(CommandLineEntryMain.java:143)
I googled a lot, seems I am all set with everything, but this exception won't go away.. Here are details: PATH=/usr/java5/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java14/jre/bin:/usr/java14/bin:/home/scuser/SC6283/RUN:/home/fpeSM/sqllib/bin:/home/fpeSM/sqllib/adm:/home/fpeSM/sqllib/misc CLASSPATH=/home/fpeSM/sqllib/java/db2java.zip:/home/fpeSM/sqllib/java/db2jcc.jar:/home/fpeSM/sqllib/java/sqlj.zip:/home/fpeSM/sqllib/function:/home/fpeSM/sqllib/java/db2jcc_license_cu.jar:. LIBPATH=/usr/lib:/lib:/home/fpeSM/sqllib/lib64
I run my script by
java -cp /home/fpeSM/sqllib/java/db2java.zip:/home/fpeSM/sqllib/java/db2jcc.jar:/home/fpeSM/sqllib/java/sqlj.zip:/home/fpeSM/sqllib/function:/home/fpeSM/sqllib/lib32:/home/fpeSM/sqllib/java/db2jcc_license_cu.jar:.:smdoctor.jar com.hp.sm.doctor.collection.commandLineConsole.CommandLineEntryMain
Can anyone tell me what's gist to make the whol开发者_JAVA百科e thing work? Many many.. thanks! P.S., libdb2jdbc.so DOES exist under /home/fpeSM/sqllib/lib64.
Even
Try telling Java where the DB2 native libraries are located by adding -Djava.library.path=/home/fpeSM/sqllib/lib64:...
to your command. Your PATH and CLASSPATH variables and command raises some questions:
- Why would you have two different versions of Java (1.4 and 5) available on the PATH?
- It seems two versions of the DB2 drivers are
available on the CLASSPATH.
db2java.zip
provides the DB2 JDBC type 2 and 4 drivers anddb2jcc.jar
provides the DB2 JDBC type 4 driver. DB2 did away with the type 2 JDBC driver somewhere around version late-8 or early-9. - Are 32-bit and 64-bit libraries installed? If you're running 32-bit Java, make sure your
library is a 32-bit library. I'm not familiar with AIX, but for Linux I would use
file libdb2jdbc.so
to check if it's a 32-bit or 64-bit library.
Even,
- what are the contents of db2java.zip file ?
- Please unzip it and see it it has any jar files and native binaries. Put jar files in classpath and binaries in path.
- If the zip contains only jar files, put all of those jar files in classpath.
- Putting zip file in classpath will not put jars inside it in classpath. You will have put extract the jar files and put them in classpath.
精彩评论