Why is DB2 Type 4 JDBC Driver looking for native library db2jcct2?(为什么 DB2 Type 4 JDBC Driver 正在寻找本机库 db2jcct2?)
问题描述
我认为 Type 4 JDBC 驱动程序是纯 Java 并且不需要本地库.
I thought the Type 4 JDBC driver was pure Java and wouldn't require native libraries.
当我将 db2jcc4.jar 放入打包为 .war 文件的 Tomcat 应用程序的 WEB-INF/lib 目录中时,尝试使用该应用程序时出现以下错误:Got SQLException: com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][4.12.55] 加载原生库 db2jcct2 失败,java.lang.UnsatisfiedLinkError
When I put db2jcc4.jar in the WEB-INF/lib directory of my Tomcat app packaged as a .war file, I get the following error when attempting to use the app: Got SQLException: com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][4.12.55] Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError
相关应用代码如下,由于清单最后一行而抛出异常:
The relevant application code is as follows and the exception is thrown due to the last line in the listing:
import com.ibm.db2.jcc.DB2SimpleDataSource;
// ...
DB2SimpleDataSource main_db2_data_source = new DB2SimpleDataSource();
main_db2_data_source.setUser(main_database_user);
main_db2_data_source.setPassword(main_database_password);
main_db2_data_source.setServerName(main_database_host);
try {
Integer main_database_port_integer = Integer.parseInt(main_database_port);
main_db2_data_source.setPortNumber(main_database_port_integer);
} catch (NumberFormatException exception) {
throw new WebException("...");
}
Connection main_connection = null;
try {
main_connection = main_db2_data_source.getConnection();
推荐答案
我怀疑问题是你没有告诉它使用类型 4 驱动程序 - 同一个 jar 文件包含类型 4 和类型 2 驱动程序,我相信.
I suspect the problem is that you haven't told it to use the type 4 driver - the same jar file contains both type 4 and type 2 drivers, I believe.
试试:
main_db2_data_source.setDriverType(4);
这篇关于为什么 DB2 Type 4 JDBC Driver 正在寻找本机库 db2jcct2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么 DB2 Type 4 JDBC Driver 正在寻找本机库 db2jcct2?
基础教程推荐
- 存储 20 位数字的数据类型 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
