JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

If I take your question literally the answer is neither. Perhaps you could post what you want to achieve through this locking and describe a short scenario? That way we can advise you on the best approach. You certainly shouldn't be considering thread synchronisation in Java to achieve this.

Jules

Frank Sikuluzu
Ranch Hand

Joined: Dec 16, 2003
Posts: 116

posted Sep 02, 2004 13:54:00

0

The scenario is simple --- The web tier offers customers chance to update some database information. Since it is possible that multiple users are online to update the database, I want to make sure that the database table (or row record) is locked when one user is updating, and that user should unlock it when he finishes. How to achieve this effect ? please provide some details. thanks,

Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823

posted Sep 02, 2004 14:53:00

0

Do you select the data for the customer to update into the web tier first? That is, could two users be looking at/updating the same record at the same time? Is that what you're talking about? If so the optimum approach depends on how frequently you expect to get a collision. Frequent collisions require a pessimistic locking strategy; occasional/infrequent/rare collisions suggest an optimistic locking strategy would be most appropriate.

Jules

Frank Sikuluzu
Ranch Hand

Joined: Dec 16, 2003
Posts: 116

posted Sep 03, 2004 13:31:00

0

Originally posted by Julian Kennedy: Do you select the data for the customer to update into the web tier first? That is, could two users be looking at/updating the same record at the same time? Is that what you're talking about? If so the optimum approach depends on how frequently you expect to get a collision. Frequent collisions require a pessimistic locking strategy; occasional/infrequent/rare collisions suggest an optimistic locking strategy would be most appropriate.

Jules

julian, I feel you are the one who can give me the answers. Please, please continue on describing the details of optimistic and pessimistic locking methods. I want to know ---

1. what kind coding I need to do ? 2. what kind special SQL or database work I need to do ?

thanks

Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823

posted Sep 03, 2004 13:55:00

0

Frank,

Of course I can give you the answers, but I'm not going to do the work for you. That's your job. If you answer my questions then maybe I can help further. I suggest you also search the web to help you to better understand the terms I've mentioned. If you run into trouble trying to implement one of the locking strategies or you feel you need further pointers I'd be happy to help.