package cc.emit.toplink; import oracle.toplink.exceptions.DatabaseException; import oracle.toplink.exceptions.ExceptionHandler; /** * TopLink exception handler: attempts to reconnect dropped connections * to the database. * * @author Renaud Waldura <renaud@waldura.com> * @version $Id: ReconnectingExceptionHandler.java,v 1.3 2003/11/03 01:43:24 renaud Exp $ */ public class ReconnectingExceptionHandler implements ExceptionHandler { public Object handleException(RuntimeException exception) { if (exception instanceof DatabaseException && (exception.getMessage().indexOf("onnection reset") > 0 || exception.getMessage().indexOf("roken pipe") > 0)) { DatabaseException ex = (DatabaseException) exception; ex.getAccessor().reestablishConnection(ex.getSession()); return ex.getSession().executeQuery(ex.getQuery()); } return null; } }