ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Edwin Lukaweski" <serj...@rogers.com>
Subject Re: Re: insert sql exception how to
Date Sun, 23 Jul 2006 14:07:37 GMT
Thank you all for the suggestions. They are all good.
    We are currently using DB2, but need to target Oracle and MySql.

    I will check to see if these have a REPLACE. I know DB2 and Oracle have 
stored procedures, but not sure about MySql.

Thanks,
Edwin

----- Original Message ----- 
From: "Larry Meadors" <lmeadors@apache.org>
To: <user-java@ibatis.apache.org>
Sent: Sunday, July 23, 2006 2:10 AM
Subject: Re: Re: insert sql exception how to


> FYI: if your database allows stored procedures, you will most likely
> increase performance 2x to 3x by making this a stored procedure...if
> that is a possibility, I would strongly suggest that you do it that
> way instead.
>
> Larry
>
>
> On 7/23/06, Jerome Gagner <phpmonkey@gmail.com> wrote:
>> What database are you using? I know a lot of the major databases have
>> "REPLACE" functionality, which would insert or update based on a key.
>>
>> -J
>>
>> On 7/22/06, Brandon Goodin <brandon.goodin@gmail.com> wrote:
>> > 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
>> > > 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