org.jcreme.sql
Interface SQLExceptionHandler

All Known Implementing Classes:
DefaultSQLExceptionHandler, SQLExceptionHandlerDB2, SQLExceptionHandlerOracle, SQLExceptionHandlerSybase

public interface SQLExceptionHandler

This interface describes how to handle the exceptions. It enabled to apply specific actions depending on the type of Exception. A handler can centralize the actions to take in an application. Handlers can also be specialized by database vendor.


Field Summary
static int EXCEPTION_TYPE_LOSS_OF_CONNECTION
          Specifies that the exception signals a loss of connection.
static int EXCEPTION_TYPE_PLAIN_DEADLOCK
          Specifies that the exception signals a deadlock that did not provoke a rollback.
static int EXCEPTION_TYPE_ROLLEDBACK_DEADLOCK
          Specifies that the exception signals a deadlock that provoked a rollback.
static int EXCEPTION_TYPE_UNKNOWN
          Specifies that the exception type is not determined.
static int WAS_HANDLED
          Specifies that the exception was successfully handled.
 
Method Summary
 int getDeadlockTimeout()
          This method gives access to the number of milliseconds that the thread will wait for before making a new attempt to resolve a deadlock.
 int getNumberOfTries()
          This method gives access to the number of attempts that will be done to resolve a deadlock (number of calls to the redo action).
 int handleException(java.sql.SQLException e)
          This method handles an SQLException.
 int handleException(java.sql.SQLException e, CremeAction rollback, CremeAction lossOfConnection)
          This method handles an SQLException.
 int handleException(java.sql.SQLException e, CremeAction rollback, CremeAction lossOfConnection, CremeAction redo)
          This method handles an SQLException.
 boolean isDeadLock(java.sql.SQLException e)
          This method can be used to test an SQLException.
 boolean isLossOfConnection(int i)
          This method can be used to test a result returned by a handleException method call.
 boolean isLossOfConnection(java.sql.SQLException e)
          This method can be used to test an SQLException.
 boolean isPlainDeadLock(int i)
          This method can be used to test a result returned by a handleException method call.
 boolean isPlainDeadLock(java.sql.SQLException e)
          This method can be used to test an SQLException.
 boolean isRolledBackDeadLock(int i)
          This method can be used to test a result returned by a handleException method call.
 boolean isRolledBackDeadLock(java.sql.SQLException e)
          This method can be used to test an SQLException.
 boolean isUnknown(int i)
          This method can be used to test a result returned by a handleException method call.
 void setDeadlockTimeout(int timeout)
          This method enables to change the number of milliseconds that the thread will wait for before making a new attempt to resolve a deadlock.
 void setNumberOfTries(int number)
          This method enables to change the number of tries attempts that will be done to resolve a deadlock (number of calls to the redo action).
 boolean wasHandled(int i)
          This method can be used to test a result returned by a handleException method call.
 

Field Detail

WAS_HANDLED

public static final int WAS_HANDLED
Specifies that the exception was successfully handled.

See Also:
Constant Field Values

EXCEPTION_TYPE_UNKNOWN

public static final int EXCEPTION_TYPE_UNKNOWN
Specifies that the exception type is not determined.

See Also:
Constant Field Values

EXCEPTION_TYPE_LOSS_OF_CONNECTION

public static final int EXCEPTION_TYPE_LOSS_OF_CONNECTION
Specifies that the exception signals a loss of connection.

See Also:
Constant Field Values

EXCEPTION_TYPE_ROLLEDBACK_DEADLOCK

public static final int EXCEPTION_TYPE_ROLLEDBACK_DEADLOCK
Specifies that the exception signals a deadlock that provoked a rollback.

See Also:
Constant Field Values

EXCEPTION_TYPE_PLAIN_DEADLOCK

public static final int EXCEPTION_TYPE_PLAIN_DEADLOCK
Specifies that the exception signals a deadlock that did not provoke a rollback.

See Also:
Constant Field Values
Method Detail

handleException

public int handleException(java.sql.SQLException e)
This method handles an SQLException. There is no special handling of deadlocks.

Parameters:
e - the exception to handle.
Returns:
the type of the exception e.

handleException

public int handleException(java.sql.SQLException e,
                           CremeAction rollback,
                           CremeAction lossOfConnection)
This method handles an SQLException. The rollback action is invoked if the exception is a rolled back deadlock.

Parameters:
e - the exception to handle.
rollback - the action to invoke to rollback.
lossOfConnection - the action to invoke in case of a loss of connection.
Returns:
the type of the exception e.

handleException

public int handleException(java.sql.SQLException e,
                           CremeAction rollback,
                           CremeAction lossOfConnection,
                           CremeAction redo)
This method handles an SQLException. The rollback action is invoked if the exception is a rolled back deadlock. The redo action is invoked if the exception is a simple deadlock.

Parameters:
e - the exception to handle.
rollback - the action to invoke to rollback.
lossOfConnection - the action to invoke in case of a loss of connection.
redo - the action to invoke in case of a simple deadlock.
Returns:
the type of the exception e.

wasHandled

public boolean wasHandled(int i)
This method can be used to test a result returned by a handleException method call.

Parameters:
i - an int produced by a handleException method call.
Returns:
true if the exception was handled, false otherwise.

isUnknown

public boolean isUnknown(int i)
This method can be used to test a result returned by a handleException method call.

Parameters:
i - an int produced by a handleException method call.
Returns:
true if the type of the exception is not known, false otherwise.

isLossOfConnection

public boolean isLossOfConnection(int i)
This method can be used to test a result returned by a handleException method call.

Parameters:
i - an int produced by a handleException method call.
Returns:
true if the exception is a loss of connection, false otherwise.

isRolledBackDeadLock

public boolean isRolledBackDeadLock(int i)
This method can be used to test a result returned by a handleException method call.

Parameters:
i - an int produced by a handleException method call.
Returns:
true if the exception is a deadlock and the transaction was rolled back, false otherwise.

isPlainDeadLock

public boolean isPlainDeadLock(int i)
This method can be used to test a result returned by a handleException method call.

Parameters:
i - an int produced by a handleException method call.
Returns:
true if the exception is a simple deadlock, false otherwise.

isLossOfConnection

public boolean isLossOfConnection(java.sql.SQLException e)
This method can be used to test an SQLException.

Parameters:
e - an SQLException to test.
Returns:
true if the exception is a loss of connection, false otherwise.

isRolledBackDeadLock

public boolean isRolledBackDeadLock(java.sql.SQLException e)
This method can be used to test an SQLException.

Parameters:
e - an SQLException to test.
Returns:
true if the exception is a deadlock and the transaction was rolled back, false otherwise.

isPlainDeadLock

public boolean isPlainDeadLock(java.sql.SQLException e)
This method can be used to test an SQLException.

Parameters:
e - an SQLException to test.
Returns:
true if the exception is a simple deadlock, false otherwise.

isDeadLock

public boolean isDeadLock(java.sql.SQLException e)
This method can be used to test an SQLException.

Parameters:
e - an SQLException to test.
Returns:
true if the exception is a deadlock (simple or not), false otherwise.

getNumberOfTries

public int getNumberOfTries()
This method gives access to the number of attempts that will be done to resolve a deadlock (number of calls to the redo action).

Returns:
the number of attempts that will be done to resolve a deadlock.

setNumberOfTries

public void setNumberOfTries(int number)
This method enables to change the number of tries attempts that will be done to resolve a deadlock (number of calls to the redo action).

Parameters:
number - the number of attempts that will be done

getDeadlockTimeout

public int getDeadlockTimeout()
This method gives access to the number of milliseconds that the thread will wait for before making a new attempt to resolve a deadlock.

Returns:
the number of milliseconds that the thread will wait for before making a new attempt to resolve a deadlock.

setDeadlockTimeout

public void setDeadlockTimeout(int timeout)
This method enables to change the number of milliseconds that the thread will wait for before making a new attempt to resolve a deadlock.

Parameters:
timeout - the number of milliseconds that the thread will wait for before making a new attempt to resolve a deadlock.


Copyright 2006 null. All Rights Reserved.