Thread:
 Getting underlying connection in JBoss 
 MjH   15 Nov 2003, 00:52 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: MjH (15 Nov 2003, 00:52) Replies: 0, Views: 39848
Subject: Getting underlying connection in JBoss
As indicated in the Notes (#1), when using the StringClobType with an
application server requires some additional code to get to the actual
database connection.  To do this in JBoss (3.2) requires the following:

- Add $JBOSS_HOME/server/default/lib/jboss-common-jdbc-wrapper.jar to
the compiler classpath.
- Add the following import statement:

  import org.jboss.resource.adapter.jdbc.WrappedConnection;

- Change the code that checks the validity of the connection object to
something like:

// Make sure connection object is right type
if (!oracleConnectionClass.isAssignableFrom(conn.getClass()))
{
  if (conn.getClass().getName().startsWith("org.jboss"))
  {
    conn = ((WrappedConnection)conn).getUnderlyingConnection();
  }
            
  if (!oracleConnectionClass.isAssignableFrom(conn.getClass()))
  {
    throw new HibernateException("JDBC connection object must be a
oracle.jdbc.OracleConnection. " +
                                 "Connection class is " +
conn.getClass().getName());
  }
}

It's not rocket science, but hopefully this note will save somebody some
time.


Maury....
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
© Copyright 2006, Red Hat Middleware, LLC. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc. [Privacy Policy]