Bonjour
J'utilise une librairie qui gere la persistence.
Mais il se peut que la connexion se coupe (BD qui redemarre, réseau qui se coupe, etc ...) et genere une DatabaseException
Cette librairie me dit d'implementer la méthode oracle.toplink.exceptions.ExceptionHandler pour remedier à ce pb
Comme ceci :
Code :
- public class ExceptionHandler implements
- oracle.toplink.exceptions.ExceptionHandler
- {
- private static Log LOG = LogFactory.getLog(ExceptionHandler.class);
- /**
- * Called by Toplink to handle the exception
- *
- * @see oracle.toplink.exceptions.ExceptionHandler#handleException(java.lang.RuntimeException)
- */
- public Object handleException(RuntimeException exception)
- {
- if (exception instanceof DatabaseException)
- {
- DatabaseException dbex = (DatabaseException) exception;
- LOG.info(" DatabaseException. Error Code: " + dbex.getErrorCode() +
- ". DB ErrorCode: " + dbex.getDatabaseErrorCode() +
- ". Message: " + dbex.getMessage());
- // 17410 - No more data to read from socket
- if (dbex.getDatabaseErrorCode() == 17410)
- {
- LOG.debug(" Found 17410: " + dbex.getErrorCode());
- dbex.getAccessor().reestablishConnection(dbex.getSession());
- return dbex.getSession().executeQuery(dbex.getQuery());
- }
- }
- // Handle all other exceptions by rethrowing
- throw exception;
- }
- }
|
Heu ... Oui
Mais je mets cette nouvelle classe ExceptionHandler où ?
Que dois-je configurer d'autres pour que cette exception qui essaie de se reconnecter puisse fonctionner ?
Merci de votre aide
Message édité par Shogun2002 le 08-01-2007 à 21:49:58