mvermand
mvermand

Reputation: 6137

Getting OracleConnection on JBoss Wildfly 8.1

I am trying to get to the underlaying Oracle connection in my WebApp on a JBoss Wildly 8.1 server.

I get an exception when I try to do the unwrap:

connection.unwrap(OracleConnection.class);

Throws

java.sql.SQLException: Not a wrapper for: oracle.jdbc.OracleConnection

The connection's class turns out to be com.sun.proxy.$Proxy37

This is my configuration in standalone.xml:

<subsystem xmlns="urn:jboss:domain:datasources:2.0">
        <datasources>
            <datasource jndi-name="java:jboss/datasources/myds" pool-name="MyPool" enabled="true">
                <connection-url>jdbc:oracle:thin:@//host:152x/blabla</connection-url>
                <driver>Oracle11g</driver>
                <security>
                    <user-name>xxx</user-name>
                    <password>yyy</password>
                </security>
            </datasource>
            <drivers>
                <driver name="Oracle11g" module="com.oracle.ojdbc6">
                    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
                </driver>
            </drivers>
        </datasources>
    </subsystem>

How can I get to the OracleConnection?

Edit: I have configured the oracle driver in the standalone.xml and the driver is added in the modules folder. In order to be able to get my code compiled, I have added a dependency in my pom-file to the driver as well. No idea if this is part of the cause.

Thanks

Upvotes: 1

Views: 2143

Answers (1)

mvermand
mvermand

Reputation: 6137

I found the solution!

When using this statement I can get to the OracleConnection object:

(oracle.jdbc.driver.OracleConnection) conn.getMetaData().getConnection();

Upvotes: 1

Related Questions