【发布时间】:2016-12-03 03:36:46
【问题描述】:
我正在尝试通过部署在 liberty websphere 机器上的 java web 应用程序访问远程机器上的 DB2 数据源。在代码执行从上下文查找数据源的那一刻,以下错误返回给我:
I FFDC1015I: An FFDC Incident has been created: "java.lang.ClassNotFoundException com.ibm.db2.jcc.DB2ConnectionPoolDataSource com.ibm.ws.injectionengine.processor.ResourceProcessor.loadTypeClass 1142" at ffdc_16.07.28_15.54.28.0.log"
W CWNEN0046W: The com.ibm.db2.jcc.DB2ConnectionPoolDataSource type specified on the resource-ref, resource-env-ref, or message-destination-ref with the jdbc/db2/primadb name in the db2-webapp.war module could not be loaded. Compatibility type checking will not be performed for this resource reference.
1)对访问数据源有帮助吗?
2)打开我打开了数据源,我想打开一个连接并在数据库上执行一个准备好的stateemnt。这里的代码应该和使用传统的javax.sql.Datasource不同吧?
我的 server.xml 的相关部分
<dataSource jndiName="jdbc/db2/primadb" type="javax.sql.DataSource">
<jdbcDriver javax.sql.DataSource="com.ibm.db2.jcc.DB2ConnectionPoolDataSource"
libraryRef="db2Lib"/>
<properties.db2.jcc driverType="4" serverName="172.17.0.3"
portNumber="50000" databaseName="PRIMADB"
user="db2inst1" password="*****"/>
</dataSource>
<library id="db2Lib">
<fileset dir="lib" includes="*.jar"/>
</library>
<application id="db2-webapp" name="Web App DB2">
<classLoader commonLibraryRef="db2Lib"/>
</application>
【问题讨论】:
-
"java.lang.ClassNotFoundException com.ibm.db2.jcc.DB2ConnectionPoolDataSource" -- 看起来驱动 JAR 不在类路径中。
-
你能用你的数据源的 server.xml 配置和资源参考更新你的问题吗?另外,您是在应用程序中直接使用 DB2 类(例如
com.ibm.db2.jcc.DB2ConnectionPoolDataSource)还是使用 JDBC 标准接口,例如javax.sql.DataSource?
标签: java jdbc docker db2 websphere-liberty