FileDocCategorySizeDatePackage
OracleValidConnectionChecker.javaAPI DocJBoss 4.2.12812Fri Jul 13 21:01:14 BST 2007org.jboss.resource.adapter.jdbc.vendor

OracleValidConnectionChecker

public class OracleValidConnectionChecker extends Object implements Serializable, org.jboss.resource.adapter.jdbc.ValidConnectionChecker
Implements check valid connection sql
author
Adrian Brock
version
$Revision: 57189 $

Fields Summary
private static final long
serialVersionUID
private static final Logger
log
private Method
ping
private static Object[]
params
Constructors Summary
public OracleValidConnectionChecker()


    
   
      try
      {
         Class oracleConnection = Thread.currentThread().getContextClassLoader().loadClass("oracle.jdbc.driver.OracleConnection");
         ping = oracleConnection.getMethod("pingDatabase", new Class[] { Integer.TYPE });
      }
      catch (Exception e)
      {
         throw new NestedRuntimeException("Unable to resolve pingDatabase method:", e);
      }
   
Methods Summary
public java.sql.SQLExceptionisValidConnection(java.sql.Connection c)

      try
      {
         Integer status = (Integer) ping.invoke(c, params);

         // Error
         if (status.intValue() < 0)
            return new SQLException("pingDatabase failed status=" + status);
      }
      catch (Exception e)
      {
         // What do we do here? Assume it is a misconfiguration
         log.warn("Unexpected error in pingDatabase", e);
      }

      // OK
      return null;