This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.
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.
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.