File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Tracking client  id for database lock Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "Tracking client  id for database lock" Watch "Tracking client  id for database lock" New topic
Author

Tracking client id for database lock

Marre Mask
Greenhorn

Joined: May 04, 2001
Posts: 19
Does anyone know a good way to implement this.
It's says in the assignment documentation that you should implement public void lock(int) and public void unlock(int). How I'm I then supposed to be able to track which client that is trying to lock and unlock the current record? Using the current threads name doesn't seem to be a adequate solution.
Any suggestions?
Rick Fortier
Ranch Hand

Joined: Jun 04, 2001
Posts: 147
I could never how to figure this out, but some people use custom socket factories to do this. I would search this NG for those messages.
The other way is that some people modify the signatures of the lock/unlock methods.
Marre Mask
Greenhorn

Joined: May 04, 2001
Posts: 19
Originally posted by Rick Fortier:
I could never how to figure this out, but some people use custom socket factories to do this. I would search this NG for those messages.
The other way is that some people modify the signatures of the lock/unlock methods.

Are you really allowed to change the signature of lock(int) and unlock(int)? It's says in the instructions "Record locking must be implemented using the methods public void lock(int) and public void unlock(int)".
Rick Fortier
Ranch Hand

Joined: Jun 04, 2001
Posts: 147
I think that it is best not to change the signatures. I did not. Others have and have passed.
There are two conflicting requirements, identify the connection for unlock is the same as lock, and the method signatures. Unless you come up with a complex answer, you will probably have to violate one or the other of these rules.
Akanimo Udoh
Ranch Hand

Joined: Jun 11, 2001
Posts: 48
Try this as a solution to this. It works and is not complex.
Dont put any of the lock/unlock checking code in your Data class. Instead put this in whatever class you're using to do remote data access. Have a signature in that class that allows you to check who locks/unlocks appropriately and depending on that you can then call the non-checking lock/unlock methods in the Data class (ie at the server end). That way all remote lock/unlocks will be checked and local lock/unlocks don't really need checking.
Akanimo.
 
IntelliJ Java IDE
 
subject: Tracking client id for database lock
 
Threads others viewed
lock() and unlock() methods
lock and unlock
Locking issue
Record locking must be implemented using the methods public void lock(int) and public
why is it necessary for unLock() to check clientID?
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture