How to get the vendor specific jdbc Connection/Statement object in JBoss 4/5
Issue
-
How do I retrieve the vendor specific jdbc Connection/Statement object in JBoss?
-
I want to use Oracle specific
oracle.jdbc.driver.OracleConnectionandoracle.jdbc.OracleCallableStatement. But I gotClassCastExceptionwhen I cast the connection object to the vendor specific connection object.When I casted to
oracle.jdbc.driver.OracleConnectionlike 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.OracleConnectionWhen I cast to
oracle.jdbc.OracleCallableStatementlike 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.