• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Transaction Control using CachedRowSet

 
Ranch Hand
Posts: 597
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am learning CachedRowSet. How do I control transation using CachedRowSet.

Suppose I have two CachedRowSets. I make changes to one of the CachedRowSet and do acceptChanges(); While making updates using another CachedRowSet, I get some database error. Now I want to rollback the changes which I made using first CachedRowSet. How do I do it?


I am using Oracle 9i Database.



I tried connection's rollback, but it doesnt work. Thanks in advance



Connection conn = null;

try {

Connection conn = DriverManager.getConnection(..);

conn.setAutoCommit(false);
Statement s = conn.createStatement();
ResultSet rs1 = conn.executeQuery(..);
ResultSet rs2 = conn.executeQuery("Some other query");
CachedRowSet cs1 = new CachedRowSetImpl();
CachedRowSet cs2 = new CachedRowSetImpl();
cs1.populate(rs1);
cs2.populate(rs2);


cs1.absolute(2);

cs1.updateString(2,"SomeValue");
cs1.updateRow();
cs1.acceptChanges(conn);

//Successful

cs2.absolute(3);

cs2.updateString(3,"SomeOtherValue");
cs2.updateRow();
cs2.acceptChanges(conn);

//Some error

conn.commit();

}
catch(Exception e)
{
conn.rollback();

}
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic