Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Tracking client id for database lock

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic