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 Sat, 22 Jul 2006 20:11:34 GMT
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