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 locking the entire database(-1) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "locking the entire database(-1)" Watch "locking the entire database(-1)" New topic
Author

locking the entire database(-1)

Ramesh kumaar
Ranch Hand

Joined: Mar 19, 2002
Posts: 146
Hello All,
Sun's Specification says
--------------------------------------------------
If the method is called with an argument of -1, the entire database should be locked.
--------------------------------------------------
What do they mean by the above statement. Who will call the lock(-1) client or server. if so what should be the effect of this. What is the need of doing this.
please all of u paricipate.

thanks & regards,
-rameshkumar
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

Who will call the lock(-1) client or server. if so what should be the effect of this. What is the need of doing this.

A typical scenario would be a server (or database) administration who will need to do some database maintanance. So that client will call lock(-1), and as soon as it returns, the server can be safely shut down, without disturbing the transactions.
Eugene.
Ramesh kumaar
Ranch Hand

Joined: Mar 19, 2002
Posts: 146
Hi Eugene Kononov,
Thanks for ur immidiate response.
--------------------------------------------------
A typical scenario would be a server (or database) administration who will need to do some database
maintanance. So that client will call lock(-1), and as soon as it returns, the server can be safely shut down, without disturbing the transactions.
--------------------------------------------------
If the maintanance is done by the severAdmin how do the client program handle that.
Can i have a seperate program which will reside in the serverside, Does the job of database locking ie which will call the lock method with -1 as an argument.
regards,
-rameshkumar.
Robin Underwood
Ranch Hand

Joined: May 01, 2002
Posts: 117
The server would call lock(-1) as part of its process of shutting down. Lock(-1) shouldn't need to be called from anywhere else for this assignment.
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

The server would call lock(-1) as part of its process of shutting down. Lock(-1) shouldn't need to be called from anywhere else for this assignment.

Just to clarify it, it think the right answer is that the server administrator will use client portion of the program (GUI) to call lock(-1) (that functionality may be password based).
But yes, for the purposes of these assignment, all we have to do is to implement lock(-1).
Eugene.
Ramesh kumaar
Ranch Hand

Joined: Mar 19, 2002
Posts: 146
Dear All,
I have planned to have a console based serverside program which will be executed when the Administrator, else I have plan to have a serverside GIU which will have a Button for starting the server, stopping the server, locking the database. Guys i need all ur feedback on this idea.
thanks,
-rameshkumar
Rishi Yagnik
Ranch Hand

Joined: Jan 04, 2001
Posts: 84
Hi all
pls do tell me where is that lock(-1) method u are talking about.....
help needed
Rishi
Ramesh kumaar
Ranch Hand

Joined: Mar 19, 2002
Posts: 146
HelloAll,
Guys all of please participate in this topic.
thanks & regards,
-rameshkumar
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

I had a simple Server gui, that had a menu with exit and help. There was one button on it to stop the server, and a status bar, which was just a JLabel in the South Region of the BorderLayout.
When the server admin clicked close, that is when it calls lock(-1) to lock all the records before shutting down the server. That way no client could corrupt the data when it closed.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Ramesh kumaar
Ranch Hand

Joined: Mar 19, 2002
Posts: 146
Thanks a lot Mark.
Here still i have one thing to be cleared. If -1 is issued(database is locked) no more new client are allowed to book the seat but the existing client should complete their task without any problem. Am i right.
regards,
rameshkumar
barry b
Greenhorn

Joined: May 28, 2002
Posts: 13
I suspect that for the SCJD you are over-complicating the design.
Lock (-1) could be issued by another program interfacing to the app, such as a database maintenance program.
Clients with existing locks would need to be able to complete their transactions and no new locks would be allowed.
For testing I put a menu option on the client app that allowed a database lock to be applied and then tried accessing from another client.
Keep it simple.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

If -1 is issued(database is locked) no more new client are allowed to book the seat but the existing client should complete their task without any problem. Am i right.

If the client gets the lock befoer the server, yes. If not then the server will be shutdown before the user can lock the record.
Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: locking the entire database(-1)