Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes How to insert all the records except the failed one. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

How to insert all the records except the failed one.

Durga Krishna
Greenhorn

Joined: Apr 05, 2007
Posts: 28
Hi,
I have a requirement in my application.
I have to insert about 1000 records into a database at a time.
So i am using batch update(to avoid performance issue).
Insertion will be done through stored procedure(MS SQL).
I will not set auto commit to false because,
out of 1000 records,if 10th record have wrong data,all the other records have to be inserted.Now the problem is,if insertion of 10th record failed,then all the first nine records are inserting succesfully.But from 10th to 1000th records are not getting inserted.
But what i want is,if 10th record is having wrong data, then except 10th record all the other records(total 999) should get inserted.Can any one suggest me the best way to do this using JDBC - CallableStatement?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"Krish",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Let me recap: you started with an invalid display name 'D K' and then changed it to something valid. Now you have changed it back to something invalid. I'll close this thread and give you a chance to correct your display name.

Please note that we take display names very seriously.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to insert all the records except the failed one.