ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brandon Goodin" <brandon.goo...@gmail.com>
Subject Re: insert sql exception how to
Date Sun, 23 Jul 2006 02:04:18 GMT
Yes you would have to check the nested exceptions to see if a SQL exception
exists.

Brandon

On 7/22/06, Edwin Lukaweski <serjann@rogers.com> wrote:
>
>  Thank you for the answer.
>
>     1) I am already commited to iBatis DAO. So, I cannot switch to Spring
>
>     2) I realize that I could do a SELECT first, but I am trying to
> optimize resources so it is best to handle the pre-existance on an exception
> basis.
>
>     3) Do I have to crawl down the exception chain, from daoexception, to
> find the SQLException?
>
> Thanks,
> Edwin
>
>
> ----- Original Message -----
> *From:* Brandon Goodin <brandon.goodin@gmail.com>
> *To:* user-java@ibatis.apache.org
> *Sent:* Saturday, July 22, 2006 4:11 PM
> *Subject:* Re: insert sql exception how to
>
> If you are just starting into this project I would recommend that you use
> Spring for your DAO factory. As far as SQL Exceptions you can use the
> getErrorCode to interpret what error it is. This will not be cross-database
> compatible. You could simply avoid the SQLException by performing a simple
> select on the database before you insert. If you have the ID then you make
> your change. If you don't have the ID you go ahead and update.
>
> Brandon
>
> On 7/22/06, Edwin Lukaweski <serjann@rogers.com> wrote:
> >
> >  Hi:
> >
> >     I need some hints as to how to handle a situation with iBatis.
> >
> >     I would like to perform an INSERT, then catch the sqlexception and
> > determine if it is caused by a duplicate key. If so, I will want to perform
> > an UPDATE to the record.
> >
> >     I realize that DAO throws a daoexception, but I am not quite sure
> > how to handle it.
> >
> >     Does anybody have any ideas?
> >
> > Thanks in advance,
> > Edwin
> >
> >
>
>

Mime
View raw message