Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation Message and JVM

 
pramod karnani
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Roel De Nijs
Sheriff
Posts: 9098
75
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic