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 One instance of application at a time use database file 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 "One instance of application at a time use database file" Watch "One instance of application at a time use database file" New topic
Author

One instance of application at a time use database file

pramod karnani
Ranch Hand

Joined: May 22, 2007
Posts: 88
Hi All,

In instruction is written
"You may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server."

Let say in standalone mode user starts application , now again he is going to start the application but at
most one program is accessing the database file
, how to do implement this logic when user is going to instance another instance of application , he shoud get message like "database file is already in use" .
how to do this?
how to get lock on database file ?

Regards,
Pramod



Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2265
    
    3

Howdy, Pramod!

Partner, this is just to indicate that you don't have to worry about another application accessing the database concurrently with your application. So when you start the server, only your application will be accessing it, so you can, for instance, load all records to a cache in memory. So you don't really have to implement anything. Also, I assumed that only one instance of the application would be running at a time.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
pramod karnani
Ranch Hand

Joined: May 22, 2007
Posts: 88
Hi Roberto,

So you did not implement this .
But what should happen if

once user started application in standalone mode.
Again user will start the application in standalone mode on same machine (same JVM) ,will application start again ? or we should give Alert message "Application is already running and database file is in used" ?
or second instance of application will start?
will Sun tester do this kind of testing of assignment ?
or Sun tester will not do this kind of testing?
I am just asking what will happen ?
what do you think?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5266
    
  13

Hi Pramod,

It's like Roberto tells you: if you may assume that just one application will access the database file, then you have to implement nothing at all. And the Sun tester will not try to do this, because that's against the instructions they gave you. So it would be stupid for him to try something like that.

You could always (it's your choice) implement something preventing this and you would add that to your choices-document, i guess then the sun tester will try to see if it works and if your solution fails, some points will be deducted. If your solution works, you will not receive extra points. Conclusion: you could only loose by doing it, so don't do it (and that's the opposite of the Nike slogan )


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: One instance of application at a time use database file