Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Transactional and non-transactional sql

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.. Where to get a good explanation regarding writing transactional and non-transactional sql? And when to use them?
 
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Cloey Tan
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Everyone is a villain in someone else's story. Especially this devious tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic