This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

URLyBird booking record

 
Tim Anlauf
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scenario :

Client A pushs button "book" -> dialog opens ( lock is invoked )
Client B pushs button "book" -> dialog opens ( try to get lock )

Client B have to wait till Client A closes the dialog ( unlock )
But maybe Client A is going to dinner... and still leaves the dialog open

Maybe someone has an idea how to solve this easlily ?
Maybe one solution is to get the lock when diaolg close ( lock/update/unlock ), but this solution isn't really good. ( because someone could override the customer id )
 
Mark Smyth
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that lock / unlock ought to be called by the GUI when a dialog box opens. You need to reconsider your design to include a layer between GUI and DB between to handle the locking and unlocking so keep the locking times minimal. Something like the followin ought to do:

(User inputs ID presses "book" button)


If there are two clients trying to book, the second one should get an error saying that the room is already booked.
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I daresay this locking mechanism is not invoked by the client application. It would be too dangerous to trust the client applications to be responsible with the record locks.

Client applications may die any moment leaving locked records on the server.

I built a business-aware wrapper class over my DBAccess implementation, and that class is responsible for the locking mechanism to be used.

Refining previous example I do it this way:


[ October 19, 2006: Message edited by: Edwin Dalorzo ]
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!