Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transactional and non-transactional sql

 
Cloey Tan
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?
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 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
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 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.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic