When I am trying to get connection with an Oracle database, I am facing this issue. My application specs are java8 + ejb + jboss-eap-7.3 + oracle 12c
Please find my code details below
My pom.xml
<dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
<type>ejb</type>
<scope>provided</scope>
<dependency>
I have added "ojdbc6.jar" in module.xml file from the path jboss-ep-7.3/modules/com/oracle/ojdbc/main
.
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);
}
After deployed this EAR into jboss 7.3, I got the below error
Caused by: java.lang.ClassCastException: org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8 cannot be cast to oracle.jdbc.OracleConnection
And I replace the below code
connection = ((WrappedConnection) conn).getUnderlyingConnection();
with this piece of code
OracleConnection oracleConnection = (OracleConnection) conn.getClass().getMethod("getUnderlyingConnection").invoke(conn);
After this code change am getting
ClassCastException: oracle.jdbc.driver.T4CConnection cannot be cast to oracle.jdbc.OracleConnection
I checked even removing the classes12.jar but no progress on that. The same I need to do for oracle19c. Please give your valuable comments to sort out this.