Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / September 2004

Tip: Looking for answers? Try searching our database.

batch update as a single transaction

Thread view: 
John Harrison - 30 Sep 2004 18:12 GMT
Hi,

I'm doing a JDBC batch update, writing several thousand rows to a single
table. As I understand it a batch update can partially succeed, so some of
my rows might get written and some not. I'd like the batch update to either
fully succeed or completely fail, commit or rollback in other words. Is that
easy to do? I'm pretty new at this.

Thanks,
John
Joe Weinstein - 30 Sep 2004 18:57 GMT
> Hi,
>
[quoted text clipped - 3 lines]
> fully succeed or completely fail, commit or rollback in other words. Is that
> easy to do? I'm pretty new at this.

Yes, easy. Set autoCommit(false) on the connection (so any subsequent work
needs to be committed). Then do batch. Check return array or whatever else
you need to do to verify whether everything went OK. If it did, call commit()
on the connection, else call rollback().

Joe Weinstein at BEA

> Thanks,
> John
John Harrison - 30 Sep 2004 19:05 GMT
> > Hi,
> >
[quoted text clipped - 8 lines]
> you need to do to verify whether everything went OK. If it did, call commit()
> on the connection, else call rollback().

OK thanks, amazingly enough that was what I was doing already.

john


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.