wood burning stoves 2.0*
The moose likes JDBC and the fly likes Transactions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Transactions" Watch "Transactions" New topic
Author

Transactions

Giuseppa Cefalu
Ranch Hand

Joined: Jul 15, 2011
Posts: 121
Hi,

It seems to me that if a trnasaction has not been commited; I should not be in the database and therefore; I should not be able to see in the result set before printing and I should not be able to see in the print out statement. In this program I commit the first insert query only; but not the second. Then I read from the database and print. It seems that as long as the select query is issued; even if the insert has has not been committed yet; the value has been inserted in the database and it can be printed. Also, the second connection; can read the data and print it becuase it is in the database. I do not udnerstand. Could any body read my code?
Thank you.



it prints thefollwing:

id name
---------
1 nameValue
2 nameValue

id name
----------
1 nameValue
2, nameValue
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

You might see a dirty read.
What happens if you uncomment your setTransactionIsolation() call for conn2?


OCUP UML fundamental and ITIL foundation
youtube channel
Giuseppa Cefalu
Ranch Hand

Joined: Jul 15, 2011
Posts: 121
I have tried uncommenting conn1 isolation level only, conn2 isolation level only and both and I keep getting the same result. I wonder if the setTransationIsolation is working. May be I need some permissions to get it working?

Giuseppa Cefalu
Ranch Hand

Joined: Jul 15, 2011
Posts: 121
This is anew version of the same problem. I have looked in many places to see how this is done and it seems that I am writing this code correctly. Still get a dirty read though. Any ideas of wht might be going wrong? The output is:
transation isolation level = 4
Transaction isolation level c1 set to 8
Transaction isolation level c2 set to 8
id name
----------
1 foo

id name
-----------
1 foo
2 bar

Thank you




 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transactions
 
Similar Threads
Error occured while initialising for loop:
Sending Email from jsp page
MySQL connection Problem
jdbc transaction mangement and behaviour
Auto Commit option fails to work