db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jim Newsham" <jnews...@referentia.com>
Subject RE: How to avoid SQLState 23505 (Violation because of duplicated key)
Date Tue, 19 Feb 2008 20:17:50 GMT

Load the data in Java code, using a while loop.  If a particular insert
fails, check the SQLState code.  If it is code 23505, ignore the exception
and continue with the next iteration of the loop, otherwise re-throw the
exception.

Jim

> -----Original Message-----
> From: Geter [mailto:geter.capellari@gmail.com]
> Sent: Monday, February 18, 2008 7:55 AM
> To: derby-user@db.apache.org
> Subject: How to avoid SQLState 23505 (Violation because of duplicated key)
> 
> 
> Hi,
> 
> I am getting SQLState 23505 on mass data loading into Derby. After
> checking
> the data being loaded I confirmed there were duplicated data causing the
> error, so the exception thrown is appropriate.
> 
> My problem is that it aborts subsequent inserts into the database. How to
> avoid Derby to abort the operation and continue to insert subsequent data?
> I
> thought in querying the database for the existing key thus avoiding an
> attempt to reinsert and existing key but it will be very costly so that I
> would like to avoid it.
> 
> Thanks in advance,
> Geter
> --
> View this message in context: http://www.nabble.com/How-to-avoid-SQLState-
> 23505-%28Violation-because-of-duplicated-key%29-tp15547074p15547074.html
> Sent from the Apache Derby Users mailing list archive at Nabble.com.
> 




Mime
View raw message