users@glassfish.java.net

Re: Catch generic DatabaseException

From: <glassfish_at_javadesktop.org>
Date: Mon, 12 Mar 2007 13:05:41 PST

Hi, i am calling flush (which i thought solved the problem previously - but looking back through my code it only allowed me to catch other exceptions - such as EntityExistsException). My code is as follows

[i]try {
  em.persist(obj);
  em.flush();
} catch (Exception ex){
  logger.info("Exception caught");
}[/i]

The problem is that the exception is caught (as the log message is generated) but the stack trace is still dumped in the log file. I've tried catching the actual exception but it doesn't make a difference.

Unfortunately, because another app alters the database remotely i get numerous exception which clutter the log files up. I would like to catch and deal with it explicitly.

I'm guessing the container is catching (and reporting) the exception before re-throwing it...
[Message sent by forum member 'jsl123' (jsl123)]

http://forums.java.net/jive/thread.jspa?messageID=207518