org.logicalcobwebs.proxool
Class FatalSqlExceptionHelper

java.lang.Object
  extended by org.logicalcobwebs.proxool.FatalSqlExceptionHelper

 class FatalSqlExceptionHelper
extends java.lang.Object

Will wrap up exceptions in another exception which can be defined at runtime.

Version:
$Revision: 1.4 $, $Date: 2005/07/01 08:02:50 $
Author:
billhorsman, $Author: billhorsman $ (current maintainer)

Field Summary
private static Log LOG
           
 
Constructor Summary
FatalSqlExceptionHelper()
           
 
Method Summary
protected static java.lang.Throwable getCause(java.lang.Throwable t)
          Tries to drill down into an exception to find its cause.
private static java.lang.reflect.Method getMethod(java.lang.Object o, java.lang.String methodName)
           
protected static boolean testException(ConnectionPoolDefinitionIF cpd, java.lang.Throwable t)
          Test to see if an exception is a fatal one
protected static boolean testException(ConnectionPoolDefinitionIF cpd, java.lang.Throwable t, int level)
          Test to see if an exception is a fatal one
protected static void throwFatalSQLException(java.lang.String className, java.lang.Throwable originalException)
          Throws a wrapped SQLException if a wrapper is defined
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final Log LOG
Constructor Detail

FatalSqlExceptionHelper

FatalSqlExceptionHelper()
Method Detail

throwFatalSQLException

protected static void throwFatalSQLException(java.lang.String className,
                                             java.lang.Throwable originalException)
                                      throws ProxoolException,
                                             java.sql.SQLException,
                                             java.lang.RuntimeException
Throws a wrapped SQLException if a wrapper is defined

Parameters:
className - the classname of the wrapping exception (must be either a RuntimeException or an SQLException). If null, then the original exception is rethrown.
originalException - the orginal exception
Throws:
ProxoolException - if there is an unexpected error with wrapping the exception
java.sql.SQLException - either the original exception, or a wrapped version of it
java.lang.RuntimeException - a wrapped up version of the orginal

testException

protected static boolean testException(ConnectionPoolDefinitionIF cpd,
                                       java.lang.Throwable t)
Test to see if an exception is a fatal one

Parameters:
cpd - the definition so we can find out what a fatal exception looks like
t - the exception to test
Returns:
true if it is fatal

testException

protected static boolean testException(ConnectionPoolDefinitionIF cpd,
                                       java.lang.Throwable t,
                                       int level)
Test to see if an exception is a fatal one

Parameters:
cpd - the definition so we can find out what a fatal exception looks like
t - the exception to test
level - the recursion level (max 20)
Returns:
true if it is fatal

getCause

protected static java.lang.Throwable getCause(java.lang.Throwable t)
Tries to drill down into an exception to find its cause. Only goes one level deep. Uses reflection to look at getCause(), getTargetException(), getRootCause() and finally getOriginalException() methods to see if it can find one. Doesn't throw an error - it will just log a warning and return a null if nothing was found.

Parameters:
t - the exception to look inside
Returns:
the original exception or null if none was found.

getMethod

private static java.lang.reflect.Method getMethod(java.lang.Object o,
                                                  java.lang.String methodName)