Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Client and server setup - database location

 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all, I have a question about choosing database location. Suppose when starting the server mode or local mode, the user enters a file that isn't the correct file (such as wrong magic cookie value, or simply blank file). Now my current approach is once they enter this value, I save it in a Properties and store into the properties file then load the main window. If wrong file, it pops up an error saying can't find or read file and exit.

Now since the file path already stored in the properties file, subsequent runs will always pop up error. Will this cause me automatically failure?? Since the properties file is generated on the fly and Sun examiners are supposed NOT to change any files. Is the properties file part of this "NOT change" business?
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each time the application is started in either Server or Standalone mode, can the user change the location of database file?

One option is that you save the file location to the properties file only if the file is correct ie the file exists on disk and magic cookie is correct. This way, user would always see the last correct file
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, K!

This was my approach: before anything, I get the database path the user provided, and verify if it exists (new File(dbLocation).exists()). If so, then I proceed and save this path in the .properties file, if not, I show a JOptionPane.showMessageDialog, saying that the path is invalid.
 
K. Tsang
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK then I guess I need to change my approach a bit. Thanks all.
 
yeah, but ... what would PIE do? Especially concerning this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic