org.dbmaintain.structure.clear.impl
Class MultiPassErrorHandler
java.lang.Object
org.dbmaintain.structure.clear.impl.MultiPassErrorHandler
public class MultiPassErrorHandler
- extends Object
This class is intended to permit multiple attempts (passes) to drop database
objects. It helps to solve the problem whereby it is impossible to drop one
database object because a dependent object exists (for example when dropping
Oracle 11 reference partitioned objects it is necessary to drop all child
tables first).
This class is used in a do-while
loop with
the method continueExecutionAfterPass()
being the loop continuation
condition.
do{
dropObjects(database);
}
while ( multiPassErrorHandler.continueExecutionAfterPass() );
In addition whenever an exception occurs it must be recorded with
the addError(RuntimeException)
method.
try {
dropObject(objectName);
} catch (RuntimeException e) {
multiPassErrorHandler.addError(e);
}
- Author:
- Mark Jeffrey
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MultiPassErrorHandler
public MultiPassErrorHandler()
addError
public void addError(RuntimeException exception)
- Call this method whenever there is an exception dropping a database
object. This method keeps track of:
- the first exception (so that it may be reported later).
- the exception count so we can determine if they are still decreasing.
If an Exception occurs during a pass then we need to do two things:
- Parameters:
exception
-
continueExecutionAfterPass
public boolean continueExecutionAfterPass()
- We stop execution if:
- We have no exceptions during the most recent pass.
We continue execution if:
- We had exceptions and it was the first pass.
- We are after the first pass and the number of exceptions is non-zero
but decreasing.
We throw the first exception of the pass if:
- After the first pass we did not have a decreasing number of
exceptions.
- Returns:
true
if we should continue execution (trying another
pass), false
if no exceptions occurred in the most
recent pass.
- Throws:
RuntimeException
- If we do not get a decreasing number of exceptions each pass
then we throw the first exception from the most recent pass.
Copyright © 2011. All Rights Reserved.