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 setAutoCommit()  problem 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 "setAutoCommit()  problem" Watch "setAutoCommit()  problem" New topic

setAutoCommit() problem

sudip narayan

Joined: Apr 18, 2004
Posts: 15
I have code which has the following structure. I am getting a set of rows using the first statement and then executing the individual statements which may be a bunch of inserts, creates or deletes or drops .
I want to commit if everything works or rollback the entire thing if there is an individual error during the execution of one of the statements.
The problem i am facing is when i have a group of inserts and a drop or create , if there is an error create or drop the inserts prior to it are commiting even though setAutoCommit(false) is set but it works fine if all of the statemnts are inserts . I appreciate your valuable suggestions. I am using oracle 9i.

resultset rs = ...;



catch(Exception e)
} // end of while

catch(Exception e1)


Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

Creates and drops default to autocommit mode regardless of your settings. DDL cannot be part of a transaction.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
pankaj patil
Ranch Hand

Joined: Dec 19, 2004
Posts: 98

Insert, update and delete comes in the data manipulation language category so the auto commit works here

where as the create and drop are data definition language so even if the setautocommit is false any modification done by the create and drop statements are auto committed by default.

Warms regards

Pankaj Patil
I agree. Here's the link:
subject: setAutoCommit() problem
It's not a secret anymore!