File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes database locking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "database locking" Watch "database locking" New topic
Author

database locking

Sarath Koiloth Ramath
Ranch Hand

Joined: May 07, 2008
Posts: 52
Hi friends,

I have 3 clients which is updating my database,these three cleints is changing the data in the database at the same time.i want to to solve make the updation one by one with out using the thread mechanism(like synchronization ).

can anyone help me to solve this issue


J 4 Java
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

Why not manage the information using an in-memory cache, which periodically dumps to the database? If you really want all 3 to have simultaneous access, database ACID principles are probably going to cause some users to get stale data exceptions. Alternatively, you could catch stale data exceptions and transparently refresh the user's data.


My Blog: Down Home Country Coding with Scott Selikoff
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1836
    
    7

It depends on the system in question, but generally speaking there are two way to go: an optimistic locking strategy or a pessimistic locking strategy.
You'll need to determine if collisions are expected to occur frequently in your multi-user system and what's an acceptable way of dealing with them when they do. The first strategy seems like the most obvious candidate for a foolproof solution, but a pessimistic approach risks compromising the performance of the system as a whole, which is something to be wary of.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: database locking