The following code is a sample application, which accesses a shared SQL database. This code seemed ok in test but causes some unrelated updates of salary to be occasionally lost in production. Why could this happen? What options are there to resolve this problem? Your suggestions will help me alot.
So, will it work if i change the call to the method mainLogic in synchronize block.
i.e., synchronize { mainLogic() }
(or) what other ways i can eliminate this problem.
Please clarify,
Thanks in advance for your help
Regards, Satya
Many thanks for you
stu derby
Ranch Hand
Joined: Dec 15, 2005
Posts: 333
posted
0
Originally posted by satya kiran: Thank you Jeanne.
So, will it work if i change the call to the method mainLogic in synchronize block.
No.
Jeanne's guessing that your problem is the classic "lost update" problem. http://db.grussell.org/section012.html#_Toc67114500 If this is you problem, this can not be fixed at the pure Java level. It can only be fixed by either having all clients use different transactionality levels (such as serializable), or by employing locking on the database.