aspose file tools*
The moose likes JDBC and the fly likes Transactional and non-transactional sql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Transactional and non-transactional sql" Watch "Transactional and non-transactional sql" New topic
Author

Transactional and non-transactional sql

Cloey Tan
Ranch Hand

Joined: Feb 03, 2009
Posts: 60
Hi.. Where to get a good explanation regarding writing transactional and non-transactional sql? And when to use them?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

I _think_ what you're asking about is writing JDBC code that is transactional yes? e.g. You want to guarantee that the SQL runs or if it fails that it rools back what it tried to do.

See Here for a tutorial on this.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Cloey Tan
Ranch Hand

Joined: Feb 03, 2009
Posts: 60
Martijn Verburg wrote:I _think_ what you're asking about is writing JDBC code that is transactional yes? e.g. You want to guarantee that the SQL runs or if it fails that it rools back what it tried to do.

See Here for a tutorial on this.


Thanks for the link you sent me. yes thats exactly what im looking for. Can you briefly explain the difference between these two? I tried to google but doesn't seem to get lots of resources regarding this.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

The first paragraph of the tutorial explains it quite clearly


There are times when you do not want one statement to take effect unless another one completes. For example, when the proprietor of The Coffee Break updates the amount of coffee sold each week, he will also want to update the total amount sold to date. However, he will not want to update one without updating the other; otherwise, the data will be inconsistent. The way to be sure that either both actions occur or neither action occurs is to use a transaction. A transaction is a set of one or more statements that are executed together as a unit, so either all of the statements are executed, or none of the statements is executed.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Cloey Tan wrote:Hi.. Where to get a good explanation regarding writing transactional and non-transactional sql? And when to use them?


When to use "non-transactional" SQL? Never. If you have SQL statements that you don't mind whether or not they are successful you probably don't need this data in a database at all, you can probably just use a file of some other suitable persistance mechanism.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transactional and non-transactional sql
 
Similar Threads
difference between datasource and transcation datasource in ejb
Transaction Attributes
MySQL - would like to know if it matters.
Non transactional with hibernate
I want to know how to use hibernate with Ms Access database