aspose file tools*
The moose likes Distributed Java and the fly likes Web Application Shared Amongst many users Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Web Application Shared Amongst many users" Watch "Web Application Shared Amongst many users" New topic
Author

Web Application Shared Amongst many users

Ayan Afridi
Greenhorn

Joined: Jan 18, 2005
Posts: 24
Hi,

I am developing a web application that will be shared by many users, in which updates/adds/deletes to database tables will occurr. I am concerned about a certain scenario:

Sample table datatable:
col1 | col2 | col3
1 | y | hi

modifiable through a screen that shows all rows in this table

1. First user (A) enters the application, and views all rows.

2. Second user (B) enters application, and views all rows.

3. User A modifies row 1, to make it into : "1, x, hi"

4. User B, still sees "1,y, hi" in the view, and modifies it to "1,y,hello"

Now the table in the db will be "1, y, hello", and user A's updates will be gone. Some will say that this is ok, but if User A's change was a critical change, that effects alot of things, then User B's change will cause possibly detrimental results.

How is this usually prevented?

One way I have thought of is, not doing User B's update if the "last update timestamp" on the screen is not the same as the one in the DB. And forcing an error there.

Or, querying the db right before any update to see what is being changed.

Another way would be to refresh all the data on the screen very often - but I don't want to put that much stress on the DB; or to refresh the data once any change has occurred- this is potentially unwieldy and could cause alot of bugs.

Any suggestions? Thanks! Much Appreciated.

-Ayan
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

Hello,
and welcome...

Search the web for optimistic locking...


SCJP, OCMJD, OCMJEA
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

One way I have thought of is, not doing User B's update if the "last update timestamp" on the screen is not the same as the one in the DB...

Yes, a optimistic locking example

Or, querying the db right before any update to see what is being changed.
Another way would be to refresh all the data on the screen very often - but I don't want to put that much stress on the DB; or to refresh the data once any change has occurred- this is potentially unwieldy and could cause alot of bugs.

There is no way to ensure that client view is up to date.
Logical consistency must be ensured server side.

Regards
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Web Application Shared Amongst many users