This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Approaches to roll back transactions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Approaches to roll back transactions " Watch "Approaches to roll back transactions " New topic
Author

Approaches to roll back transactions

Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
Hi,

When I want to roll back a transaction I use this method:

conn.setAutoCommit( false );
....
if ( error )
conn.rollback();

The problem is that I use a mySQL database and have to convert the tables from myISAM to innoDB! I don�t like that, because it gives you some problem when making a copy of the database and open the new database, then all the innoDB tables can�t open again!

Because of that I will hear if there are other ways to make roll back transactions? What about executeBatch()?
[ April 10, 2005: Message edited by: Jeppe Fjord ]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30050
    
149

Jeppe,
Take a look at XA drivers. They use two phase commit to roll back transactions across multiple databases.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
MySQL does not support XA or JTA...(except mySQL 5.0)

(http://e-docs.bea.com/wls/docs90/jdbc_admin/third_party_drivers.html)
[ April 10, 2005: Message edited by: Jeppe Fjord ]
 
Consider Paul's rocket mass heater.
 
subject: Approaches to roll back transactions
 
Similar Threads
Container managed transaction (CMT) doesn't commit transactions
how to insert into 2 tables at a time?
Important Query about nested transaction in EJB
Transaction not rolling back if I call ejbSelectXXX()
mysql autocommit