How to get the vendor specific jdbc Connection/Statement object in JBoss 4/5

Solution Verified - Updated -

Issue

  • How do I retrieve the vendor specific jdbc Connection/Statement object in JBoss?

  • I want to use Oracle specific oracle.jdbc.driver.OracleConnection and oracle.jdbc.OracleCallableStatement. But I got ClassCastException when I cast the connection object to the vendor specific connection object.

    When I casted to oracle.jdbc.driver.OracleConnection like the following code:

    javax.sql.DataSource ds = (javax.sql.DataSource) (new javax.naming.InitialContext()).lookup("java:OracleDS");
    oracle.jdbc.driver.OracleConnection oracleConn = (oracle.jdbc.driver.OracleConnection) ds.getConnection();
    

    then I got the following ClassCastException:

    java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast to oracle.jdbc.driver.OracleConnection
    

    When I cast to oracle.jdbc.OracleCallableStatement like the following code:

    javax.sql.DataSource ds = (javax.sql.DataSource)  (new javax.naming.InitialContext()).lookup("java:OracleDS");
    java.sql.Connection con = (java.sql.Connection) ds.getConnection();
    oracle.jdbc.OracleCallableStatement oracleStmt = (oracle.jdbc.OracleCallableStatement ) con.prepareCall(sqlstring);
    

    then I got the following ClassCastException:

    java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.jdk6.WrappedCallableStatementJDK6 cannot be cast to oracle.jdbc.OracleCallableStatement
    

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 4.x
    • 5.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content