John Dixon wrote:
> The App:
> I have a JSP page that collects data from a database and displays it in
> textfields. The user can change the data. click OK and the database is
> updated.
>
> The question: How do I lock the record in the database so that another user
> cannot change the data whilst this user is in the midst of changing the
> data. Using MSSQLServer.

_really_ bad plan. Use optimistic locking and when the user commits
check to see if the record has changed in between loading and trying to
save.

Why? Otherwise:
1. User locks record by starting to view.
2a. User goes to lunch and leaves record locked for one hour.
2b. User goes home and leaves locked overnight.
2c. User dies/machine turned off/ whatever and record never unlocked.

Basically, given the limitations of http and browsers, doing any form of
locking is IMHO a bad idea. You just have no way of knowing when the
next request is ever going to come in to unlock/commit changes to a
record.

Jari

--
Jari Worsley
Senior Programmer
Hyperlink plc

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to