How do I access the specific driver Connection with JBoss ?

If you need to access to the specific driver connection (for example the OracleConnection instead of the java.sql.Connection) then you need to use the WrappedConnection object and get its underlying connection:

Connection c = dataSource.getConnection();
org.jboss.resource.adapter.jdbc.WrappedConnection wc = (WrappedConnection) c;
OracleConnection ajc = (OracleConnection ) wc.getUnderlyingConnection();

Or another way, using reflection:

public static OracleConnection getOracleConnection(Connection conFromPool)
throws SQLException {

  try {
    Class[] parms = null;
    Method method =
      (conFromPool.getClass()).getMethod("getUnderlyingConnection",
                                       parms);
    return (OracleConnection) method.invoke(conFromPool, parms);

  } catch (InvocationTargetException ite) {
    throw new SQLException(ite.getMessage());
  } catch (Exception e) {
    throw new SQLException(e.getMessage());
  }
}

Related articles available on mastertheboss.com

How to deploy a DataSource in jboss at application level ?

  Do you need to deploy your DataSource along with your Enterpri

JBoss Datasource HA

This tutorial has been updated for the new release of JBoss Appli

JBoss run out of Connections ?

Have you got No ManagedConnections available error message ? well

How to connect to a DataSource from a remote client?

  If you want to connect to your JBoss Connection Pool from a re

JBoss Datasource configuration

A Datasource is a Java Naming and Directory Interface (JNDI) obje

How do I get the list of Datasources available ?

JBOSS AS 4/5 Users You can use either twiddle: $ twiddle.sh que

Follow us on Twitter