aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Validation Message and JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Validation Message and JVM" Watch "Validation Message and JVM" New topic
Author

Validation Message and JVM

pramod karnani
Ranch Hand

Joined: May 22, 2007
Posts: 88

Hi All,

I have few questions


Q.1 If user is starting application in standalone mode and when he has to specify the database file location , let say if user does not specify the database file location file properly then should we give Alert message "Please specify the database file"?
Our application should be designed only for the database file given to us (specific to our assignment)?
Let say if user specify other file that also ends with .db(but not the database file whatever Sun has given) then still should we give aler message "Please specify the database file" ?
or our application should be designed for all the database file those have extension .db ?

JVM
In standalone mode can we run more than one instance of application (ApplicationRunner which is starting point to start the applicaton )on one JVM ?


Regards
Pramod
Axel Leucht
Greenhorn

Joined: Jan 19, 2009
Posts: 21
I don't let the user proceed without specifying the database location.

I'm disabling the Ok button in my JOptionPane and enable it only when the file exists, is readable and writable and has the proper magic cookie in its header.


Regards

SCJP, SCJD
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2266
    
    3

Howdy, Pramod!

Partner, for Q1, here's what I did: when the user provides the database location in standalone mode, the first thing that I do is verify if the given file exists; if so, I proceed and verify if the given file has the right "magic cookie". So you end up having to make assumptions here. For instance, I assumed that the right database file must have the same magic cookie value as the one present in the database that was provided to me, but I already saw some people that ignored this value. If the magic cookie value present in the given file matches the magic cookie value of the database that was provided to me, then everything proceeds normally, otherwise, I show a message dialog, informing that the provided database is invalid. And I chose to hardcode this value, so I could verify it every time the application starts.

For the other question, 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
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5402
    
  13

Hi pramod,

Q1. you should be able to process each valid database-file. So i let user choose any *.db file and if that's a valid file (not empty, correct magic cookie, readible file, writable file,...) server or standalone client will start. otherwise error message is shown.

Q2. my instructions clearly tell me

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.


[edit] I see that i was beaten in speed by Axel and Roberto


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: Validation Message and JVM