1)先要从下面目录
[db2inst@linux01 java]$ pwd
/home/db2inst/sqllib/java
复制db2java.jar ,db2jcc.jar ,db2jcc_license_cu.jar 到
/weblogic/user_projects/domains/test_domain/lib
这个目录里的README.txt说的很清楚,这个目录里的.jar文件会在weblogic启动时自动加到CLASSPATH的最后。
这样,在Weblogic启动时可以看到下面的日志:
<Jan 25, 2011 1:56:07 AM CST> <Notice> <WebLogicServer> <BEA-000395> <Following extensions directory contents added to the end of the classpath:
/weblogic/user_projects/domains/test_domain/lib/db2java.jar:/weblogic/user_projects/domains/test_domain/lib/db2jcc.jar:/weblogic/user_projects/domains/test_domain/lib/db2jcc_license_cu.jar>
2)这个完了之后,按照标准做法仍然不行。在Test Configuration时会收到下面的错误提示:
Connection test failed.
Cannot load driver: COM.ibm.db2.jdbc.app.DB2Driver
很误导人的一个提示
如果创建JDBC时采用Other,来手动指定Driver Class Name等设定之后在Test Configuration时会提示
找不到 db2jcct2云云...
其实时找不到libdb2jcct2.so can't load db2jcct2(windows为db2jcct2.dll)
需要做的就是
]# export LD_LIBRARY_PATH=/home/db2inst/sqllib/lib:$LD_LIBRARY_PATH
然后重起Weblogic,再创建JDBC就没有任何问题了,无论Database Driver用DB2的还是Oracle(weblogic)的。
看来还是没有把/home/db2inst/sqllib/lib加到LD_LIBRARY_PATH里造成的。
针对不同操作系统:
On Windows?:
Add the path that includes the db2jcct2.dll file to the PATH variable. By default, the db2jcct2.dll file is located in %DB2HOME%\bin.
On UNIX:
DB2 Content Manager V8.4 and its APIs load libdb2jcct2.so from DB2 instance library path defined in LD_LIBRARY_PATH or LIBPATH variable.
32-bit DB2 Instance:
Make sure that the DB2 instance library path exists in LD_LIBRARY_PATH (Solaris? or Linux) or LIBPATH (AIX?). For example:
For Solaris: export LD_LIBRARY_PATH=/export/home/db2inst1/sqllib/lib:$LD_LIBRARY_PATH
For Linux: export LD_LIBRARY_PATH=/home/db2inst1/sqllib/lib:$LD_LIBRARY_PATH
For AIX: export LIBPATH=/home/db2inst1/sqllib/lib:$LIBPATH
64-bit DB2 Instance:
For 64-bit DB2 instance, [DB2 Instance Dir]/sqllib/lib links to 64-bit library directory. The following is the link relationship of the DB2 library directory on UNIX:
[DB2 Instance Dir]/sqllib/lib -> [DB2 Instance Dir]/sqllib/lib64 -> [DB2 Product Installation Dir]/lib64
[DB2 Instance Dir]/sqllib/lib32 -> [DB2 Product Installation Dir]/lib32
But DB2 Content Manager V8.4 supports only the 32-bit libdb2jcct2.so. To make DB2 Content Manager V8.4 and its APIs work correctly, the path to 32-bit libraries must be listed before the path to the 64-bit libraries in LD_LIBRARY_PATH or LIBPATH.
For example:
For AIX?: export LIBPATH=/opt/IBM/db2/V9.1/lib32:$LIBPATH
#weblogic&oracle app server
--转自