Originally posted by kwwong wong:
I am developing an application using Oracle database. The application has several client. The application has a page list all records in the table. When user click the row, it will goto edit page for user update.
The problem is when two user edit the same record at the same time, the last user will overwrite the previous user.
Is it need to add a timestamp in the table and every time user edit the record, I save the timestamp in the edit page. And then when the user click the update button to update the record, I will compare the timestamp before update or using a timestamp as one of the key when update?
But I hope that before the user enter to the edit page, I can check that whether the record is updated by another user. When it is, I can prevent the user enter to the edit page for that record. How to implement this mechanism when using JSP/Servlet/JavaBean only ?
Thanks
James Carman, President<br />Carman Consulting, Inc.
Originally posted by James Carman:
When an edit request comes in, it must pass the version number with it. If the version number passed in matches the version number in the database, the edit can proceed.
Originally posted by Hartmut Ludwig:
How do you solve the problem with simultaneous access? First come first served, the version number is changed and the second person that also has done some editing won't be able to save it and won't know why... I think it's better to tell that the record is locked so the person can try later.
sl
Hartmut
James Carman, President<br />Carman Consulting, Inc.
Originally posted by kwwong wong:
If user A go to edit record A but without update the record, and then he go to edit record B. At this time, record A and B also has the session ID for user A. On the same time, if user B try to edit the record A, because user A session alive at this time, user B cannot enter to edit page for record A. The record A is locked until the user A's session died.
James Cook<br />Sun Certified Java 2 Developer
Originally posted by kwwong wong:
However, when the user exit the current edit page without click any button, i.e. using backpage button in browse or the menu I provided. In this case, I have no opportunity to remove the sessionID.
When the user go to another page and then also exit the page without click any button. He can lock many record (in clude another tables) at the same time.
Originally posted by kwwong wong:
However in the valueUnbound method, I need to scan all the tables with the sessionID to unlocks all locks of the according session.
I have another ideal to implement the locking mechanism. Can I store the locking information in ServletContext instead of tables column ?
But I don't know how to implement the collection. Using Collection , Vector, List or implement by myself ?