Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

setAutoCommit() problem

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
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.

try
{
conn.setAutoCommit(false);
resultset rs = ...;

while(rs.next())
{

try
{

}
catch(Exception e)
{
conn.rollback();
}
} // end of while

}
catch(Exception e1)
{

}

regards
VVS
 
author & internet detective
Posts: 40035
809
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sree,
Creates and drops default to autocommit mode regardless of your settings. DDL cannot be part of a transaction.
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

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
 
Water! People swim in water! Even tiny ads swim in water:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic