How to ensure concurrency control in servlets?
Posted on 2001-08-24
Hi, may I know how to handle multiple requests to the same servlet that will update the database with the correct implementation of concurrency control?
Let's say we get the number of items in the database table. "Select count(*) from Item" returns 100.
Next we add a new Item using 100 + 1 = 101 as the item_id
Now how can I ensure that the item_id is unique, no two requests starting at the same time has added the item_id, 101 into the database?