问题描述
当我尝试与Oracle数据库建立连接时,我遇到了这个问题。我的应用程序规格是java8 + ejb + jboss-eap-7.3 + oracle 12c
请在下面找到我的代码详细信息
我的pom.xml
<dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
<type>ejb</type>
<scope>provided</scope>
<dependency>
我已从路径jboss-ep-7.3/modules/com/oracle/ojdbc/main
在module.xml文件中添加了“ ojdbc6.jar”。
My DBConnection.java
CallableStatement statement;
Connection connection;
ArrayDescriptor descriptor;
Connection conn = datasourceObj.getconnection(dev);
try {
statement = conn.prepareCall(callString);
connection = ((WrappedConnection)
conn).getUnderlyingConnection();
descriptor = ArrayDescriptor.createDescriptor("NUM_ARRAY",connection);
}
将此EAR部署到jboss 7.3中之后,出现以下错误
由于:java.lang.classCastException: 无法强制转换org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8 到oracle.jdbc.OracleConnection
我替换下面的代码
connection = ((WrappedConnection) conn).getUnderlyingConnection();
使用这段代码
OracleConnection oracleConnection = (OracleConnection) conn.getClass().getmethod("getUnderlyingConnection").invoke(conn);
此代码更改后得到
ClassCastException:oracle.jdbc.driver.T4CConnection无法强制转换为 oracle.jdbc.OracleConnection
我什至删除了classes12.jar,但没有任何进展。我需要对oracle19c做同样的事情。请给出您的宝贵意见以解决此问题。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)