File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Commit & Rollback in Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Commit & Rollback in Java?" Watch "Commit & Rollback in Java?" New topic
Author

Commit & Rollback in Java?

Fantine Ponter
Ranch Hand

Joined: Aug 11, 2008
Posts: 30
I'm learning Java, and am an absolute beginner (page 243 Head First Java), but was wondering about the following:

1) How does Java deal with Commit and Rollback situations during transaction processing?

2) Are there any reserved words to that effect?

Thank you for your time
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40041
    
  28
Java doesn't deal with commit, nor with rollback. That is done by the database program. The keywords are "commit" and "rollback" but they are both SQL keywords, not Java keywords.

This thread would sit better on the JDBC forum, so I shall move it.
Fantine Ponter
Ranch Hand

Joined: Aug 11, 2008
Posts: 30
thank you. I apologize for entering my question in the wrong spot.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40041
    
  28
You're welcome There is no need to feel bad about where you posted.
[ November 26, 2008: Message edited by: Campbell Ritchie ]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31057
    
232

Fantine,
There are methods with those names in Java. If you decide to handle transactions explicitly, you can choose to commit or rollback.


[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
Fantine Ponter
Ranch Hand

Joined: Aug 11, 2008
Posts: 30
Thank you Jeanne.

As a matter of interest, which class(es) do those methods belong to? Are they in the Java API?

I would try to test it now if I were further advanced in my Java studies, but will have to wait until i know a few more things. I have not learnt how to call SQL in Java yet, nor do I know how to read a file or write to a file yet.

It actually isn't important for me to know the answers, as I said before, I was just curious to see how Java programming handles commit and rollback.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


As a matter of interest, which class(es) do those methods belong to? Are they in the Java API?

In the context of JDBC thay are methods on the Connection class.

I'm not sure you have seen this yet, but if you have a method name and you want to find out what class it belongs to, have a look at the index that JavaDoc tool produces.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Fantine Ponter
Ranch Hand

Joined: Aug 11, 2008
Posts: 30
Wow! So much to learn, so little time... Thanks Paul. I've saved the site as a favourite.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Commit & Rollback in Java?