EAP did not accept the java sql connection

Solution Verified - Updated -

Issue

  • User has used Connections returned from an Oracle Connection Pool (connection pool was setup in EAP using JDBC datasource); but noticed something strange
  • User is getting back instances of oracle.jdbc.OracleConnection rather than java.sql.Connection.
  • This prevents to use the generic connection (java.sql.Connection)

  • Following lines of code returns the connection object:

ctx = new InitialContext();
ds = (DataSource)ctx.lookup("java:jboss/datasources/testDS");
conn = ds.getConnection();

if (conn.isWrapperFor(OracleConnection.class)) {

      oracleConnection= conn.unwrap(OracleConnection.class);  

 } else {
       // recover, not an oracle connection
 }

  • The issue here is, user is unable to use the normal JDBC Connection.
  • User want to accept the java.sql.Connection and we want to use it.
  • User DO NOT want to use OracleConnection.
  • But, while tring to use the returned JDBC Connection, it is giving WrappedConnection exception.
  • Following line in our code raises this exception.
createPersonRequestXMLType = new XMLType(conn, inputMSGString);
  • The types in the above line of code are
createPersonRequestXMLType : oracle.xdb.XMLType
conn : java.sql.Connection
inputMSGString : String
  • When user change the type of conn to OracleConnection (after Unwrapping the connection using oracleConnection = conn.unwrap(OracleConnection.class);), then everything starts to work again.

  • The question here is:

  • How to use normal connection instead of OracleConnection? The same piece of code has worked in Weblogic without any problem; so user think this is a bug in JBoss EAP connection pooling?

  • Will JDBC connection returned from JBoss EAP Connection Pool (to Oracle) work with XMLType ? i.e. in the code
    createPersonRequestXMLType = new XMLType(conn, inputMSGString);

  • User tried JDBC conenction obtained directly (not through JBoss Conenction Pool) and then it worked.

  • Jboss connection pool returns org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6 instead of Connection object which implements java.sql.Connection interface - is this normal ? Is this the way other connection pools are implemented ?

  • If user still want to use normal java.sql.Connection, XMLType and Connection Pooling, what are the alternatives?

  • User is making a product that should adhere to J2EE standards. So, want to pass Java.sql.Connection.

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In