File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Batch DB Updatation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Batch DB Updatation" Watch "Batch DB Updatation" New topic

Batch DB Updatation

Sam Furtado
Ranch Hand

Joined: Jul 16, 2002
Posts: 45
Hi Guys !!!
Below is a piece of code:
Statement stmt = con.createStatement();
int[] updateCounts = stmt.executeBatch();
catch(BatchUpdateException bueExcep){}
Here, batch updations take place dynamically through a user interface wherein the user casn specify the sql scripts to be fired. However, for instance if the first sql script is correct but the ones later on are incorrect then the entire transaction should be rolled back since the entire code is within "con.setAutoCommit(false);" and "con.commit();". Unfortunately, this does not occur and the first script does get executed successfully. What should be done to rectify it !!!
Pls suggest.
Thanks Guys

Sun Certified Java Programmer<br />Sun Certified Web Component Developer
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

This is behaviour is JDBC driver specific. I use Oracle thin drivers and they behave the same. It's all or nothing. The best you can do is validity checking of the fields before you add them to batch (unless you can find a different driver that behaves the way you want it to).
I agree. Here's the link:
subject: Batch DB Updatation
It's not a secret anymore!