You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Alex Sherwin <al...@acadiasoft.com> on 2009/12/03 22:15:37 UTC

IBatis 3 Exceptions

Why does IBatis 3.0 throw IbatisException (RuntimeException) instead of 
checked exceptions?

Is this a limitation now due to the dynamic nature of the generic typed 
mapped statement classes?  IbatisException doesn't even seem to wrap 
SQLException, I see it wrapping the native exceptions from my JDBC 
driver (MySQL).

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: IBatis 3 Exceptions

Posted by Zach Visagie <za...@ipay.co.za>.
We have a custom db connection pool which checks error codes/sql states 
on the SQLException and determines whether a reconnect is necessary 
(cheaper than running a validation query). But this happens behind the 
scenes and not on the business layer.

Spring's DataAccessException hierarchy also works on checking vendor 
specific codes and translating those into useful vendor neutral 
exceptions for things like a duplicate record inserted or deadlock.

I have also come to dislike checked exceptions...


Zach


On Fri, 4 Dec 2009 11:27:26 -0600
Rick.Wellman <Ri...@kiewit.com> wrote:

> Agreed on both points below... but am curious to the community at
> large... has anyone come up with something useful to do on a database
> exception other than apologize to the user?  This might be a good forum
> to share.
> 
>  
> 
> From: Clinton Begin [mailto:clinton.begin@gmail.com] 
> Sent: Thursday, December 03, 2009 7:47 PM
> To: user-java@ibatis.apache.org
> Subject: Re: IBatis 3 Exceptions
> 
>  
> 
> Nope.  Nothing technical.  I just happen to hate checked exceptions.
> :-)
> 
> The original exception is always nested within the runtime one though,
> so you have full access to everything you need.  
> 
> There is a bit of placeholder code where I had intended to build a
> hierarchy of exceptions, similar to Spring's exceptions.  But honestly,
> I cannot recall a time in my 12 years of Java coding when I could
> actually do something useful with a database exception, other than
> apologize to the user with a dialog box.  
> 
> Clinton
> 
> On Thu, Dec 3, 2009 at 2:15 PM, Alex Sherwin
> <al...@acadiasoft.com> wrote:
> 
> Why does IBatis 3.0 throw IbatisException (RuntimeException) instead of
> checked exceptions?
> 
> Is this a limitation now due to the dynamic nature of the generic typed
> mapped statement classes?  IbatisException doesn't even seem to wrap
> SQLException, I see it wrapping the native exceptions from my JDBC
> driver (MySQL).
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
> 
>  
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


RE: IBatis 3 Exceptions

Posted by Thijs <vo...@gmail.com>.
We use it.
We use an oracle database with some business logic/rules in the SQL
triggers. We have defined custom SQL exceptions that are thrown when certain
rules fail.

Based on the exception code we let the business logic from the application
decide if it should show an error or automatically retry with different
values.





Rick.Wellman wrote:
> 
> Agreed on both points below... but am curious to the community at
> large... has anyone come up with something useful to do on a database
> exception other than apologize to the user?  This might be a good forum
> to share.
> 
>  
> 
> From: Clinton Begin [mailto:clinton.begin@gmail.com] 
> Sent: Thursday, December 03, 2009 7:47 PM
> To: user-java@ibatis.apache.org
> Subject: Re: IBatis 3 Exceptions
> 
>  
> 
> Nope.  Nothing technical.  I just happen to hate checked exceptions.
> :-)
> 
> The original exception is always nested within the runtime one though,
> so you have full access to everything you need.  
> 
> There is a bit of placeholder code where I had intended to build a
> hierarchy of exceptions, similar to Spring's exceptions.  But honestly,
> I cannot recall a time in my 12 years of Java coding when I could
> actually do something useful with a database exception, other than
> apologize to the user with a dialog box.  
> 
> Clinton
> 
> On Thu, Dec 3, 2009 at 2:15 PM, Alex Sherwin
> <al...@acadiasoft.com> wrote:
> 
> Why does IBatis 3.0 throw IbatisException (RuntimeException) instead of
> checked exceptions?
> 
> Is this a limitation now due to the dynamic nature of the generic typed
> mapped statement classes?  IbatisException doesn't even seem to wrap
> SQLException, I see it wrapping the native exceptions from my JDBC
> driver (MySQL).
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
> 
>  
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/IBatis-3-Exceptions-tp26633327p26656890.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: IBatis 3 Exceptions

Posted by Clinton Begin <cl...@gmail.com>.
I have done things like retry logic and/or switching to a different database
in a cluster -- but at all costs I try to do that at the driver level (with
a driver proxy class), rather than in the business logic.  But even if I did
it in the business logic, while I might catch the exception for the retry, I
would not distinguish the failure.

This is really rare though, and I can't remember the last time I did it.
Currently where I work they do the cluster failover logic in a driver proxy
as I mentioned.

Cheers,
Clinton

On Fri, Dec 4, 2009 at 10:27 AM, Rick.Wellman <Ri...@kiewit.com>wrote:

>  Agreed on both points below… but am curious to the community at large…
> has anyone come up with something useful to do on a database exception other
> than apologize to the user?  This might be a good forum to share.
>
>
>
> *From:* Clinton Begin [mailto:clinton.begin@gmail.com]
> *Sent:* Thursday, December 03, 2009 7:47 PM
> *To:* user-java@ibatis.apache.org
> *Subject:* Re: IBatis 3 Exceptions
>
>
>
> Nope.  Nothing technical.  I just happen to hate checked exceptions.  :-)
>
> The original exception is always nested within the runtime one though, so
> you have full access to everything you need.
>
> There is a bit of placeholder code where I had intended to build a
> hierarchy of exceptions, similar to Spring's exceptions.  But honestly, I
> cannot recall a time in my 12 years of Java coding when I could actually do
> something useful with a database exception, other than apologize to the user
> with a dialog box.
>
> Clinton
>
> On Thu, Dec 3, 2009 at 2:15 PM, Alex Sherwin <al...@acadiasoft.com>
> wrote:
>
> Why does IBatis 3.0 throw IbatisException (RuntimeException) instead of
> checked exceptions?
>
> Is this a limitation now due to the dynamic nature of the generic typed
> mapped statement classes?  IbatisException doesn't even seem to wrap
> SQLException, I see it wrapping the native exceptions from my JDBC driver
> (MySQL).
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>
>

Re: IBatis 3 Exceptions

Posted by Larry Meadors <la...@gmail.com>.
Email the server admin? :D

Larry


On Fri, Dec 4, 2009 at 10:27 AM, Rick.Wellman <Ri...@kiewit.com> wrote:
> Agreed on both points below… but am curious to the community at large… has
> anyone come up with something useful to do on a database exception other
> than apologize to the user?  This might be a good forum to share.
>
>
>
> From: Clinton Begin [mailto:clinton.begin@gmail.com]
> Sent: Thursday, December 03, 2009 7:47 PM
> To: user-java@ibatis.apache.org
> Subject: Re: IBatis 3 Exceptions
>
>
>
> Nope.  Nothing technical.  I just happen to hate checked exceptions.  :-)
>
> The original exception is always nested within the runtime one though, so
> you have full access to everything you need.
>
> There is a bit of placeholder code where I had intended to build a hierarchy
> of exceptions, similar to Spring's exceptions.  But honestly, I cannot
> recall a time in my 12 years of Java coding when I could actually do
> something useful with a database exception, other than apologize to the user
> with a dialog box.
>
> Clinton
>
> On Thu, Dec 3, 2009 at 2:15 PM, Alex Sherwin <al...@acadiasoft.com>
> wrote:
>
> Why does IBatis 3.0 throw IbatisException (RuntimeException) instead of
> checked exceptions?
>
> Is this a limitation now due to the dynamic nature of the generic typed
> mapped statement classes?  IbatisException doesn't even seem to wrap
> SQLException, I see it wrapping the native exceptions from my JDBC driver
> (MySQL).
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


RE: IBatis 3 Exceptions

Posted by "Rick.Wellman" <Ri...@kiewit.com>.
Agreed on both points below... but am curious to the community at
large... has anyone come up with something useful to do on a database
exception other than apologize to the user?  This might be a good forum
to share.

 

From: Clinton Begin [mailto:clinton.begin@gmail.com] 
Sent: Thursday, December 03, 2009 7:47 PM
To: user-java@ibatis.apache.org
Subject: Re: IBatis 3 Exceptions

 

Nope.  Nothing technical.  I just happen to hate checked exceptions.
:-)

The original exception is always nested within the runtime one though,
so you have full access to everything you need.  

There is a bit of placeholder code where I had intended to build a
hierarchy of exceptions, similar to Spring's exceptions.  But honestly,
I cannot recall a time in my 12 years of Java coding when I could
actually do something useful with a database exception, other than
apologize to the user with a dialog box.  

Clinton

On Thu, Dec 3, 2009 at 2:15 PM, Alex Sherwin
<al...@acadiasoft.com> wrote:

Why does IBatis 3.0 throw IbatisException (RuntimeException) instead of
checked exceptions?

Is this a limitation now due to the dynamic nature of the generic typed
mapped statement classes?  IbatisException doesn't even seem to wrap
SQLException, I see it wrapping the native exceptions from my JDBC
driver (MySQL).

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org

 


Re: IBatis 3 Exceptions

Posted by Clinton Begin <cl...@gmail.com>.
Nope.  Nothing technical.  I just happen to hate checked exceptions.  :-)

The original exception is always nested within the runtime one though, so
you have full access to everything you need.

There is a bit of placeholder code where I had intended to build a hierarchy
of exceptions, similar to Spring's exceptions.  But honestly, I cannot
recall a time in my 12 years of Java coding when I could actually do
something useful with a database exception, other than apologize to the user
with a dialog box.

Clinton

On Thu, Dec 3, 2009 at 2:15 PM, Alex Sherwin <al...@acadiasoft.com>wrote:

> Why does IBatis 3.0 throw IbatisException (RuntimeException) instead of
> checked exceptions?
>
> Is this a limitation now due to the dynamic nature of the generic typed
> mapped statement classes?  IbatisException doesn't even seem to wrap
> SQLException, I see it wrapping the native exceptions from my JDBC driver
> (MySQL).
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>