openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wes Wannemacher <>
Subject Re: how do you manage db exceptions?
Date Sat, 29 Nov 2008 07:52:24 GMT
I'm not sure if this is a question specific to openjpa, but it doesn't
seem like it, so I will answer as though it is not. In general, whenever
working at a level that would encounter a Sql Exception, I catch them
and wrap them in an application specific Exception that is unchecked. I
don't think I've ever had a SQLException that application code can
recover. Or, at least, never have I come across a situation where the
effort to recover from the exception is worthwhile. 

Lately, I have been using Spring quite a bit... Within Spring's database
APIs, SQLExceptions are caught and wrapped in much more useful
exceptions that are unchecked. 


On Fri, 2008-11-28 at 23:34 -0800, is_maximum wrote:
> Hi
> I am eager to know haow do you deal with Sql exceptions which are unchecked
> and cannot be determined at runtime. for example, unique constraint
> exception, integrity exception etc.
> What I know is that all these sort of exceptions are wrapped in SQLException
> but is there any way to distinguish them and create appropriate message to
> the user.
> I appreciate if you share your experiences on this

View raw message