This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Database File Format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Database File Format" Watch "Database File Format" New topic

Database File Format

Travis Zimmerman

Joined: Mar 06, 2002
Posts: 27
Has anyone taken care of the case where a user would try to open the wrong type of db file( ie .bat or .xls ). There is no default handling of this in the Data file and the results are undefined.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Travis,
Why give a user the option to open the wrong file type? Since we already know the name of the database (ie db.db) why not simply use that given to "idiot-proof" the database bootstrap code? For remote mode, the database should probably be in the same directory as the server and for local mode in the same directory as the client. By doing it that way you remove any chance of selecting an invalid file. You simply start the database without any user input.
That's my opinion anyway
Michael Morris

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Najib Coutya

Joined: Dec 18, 2001
Posts: 28
I think you need to allow the user to launch the server with the database file s/he wiches to use.
In case the user enters the wrong database name, the data file will fail to open resulting in an exception which should be handled and dumped properly on the screen where the user tried to launch the server from.
Travis Zimmerman

Joined: Mar 06, 2002
Posts: 27
Yes, the exceptions should be caught. However, any number of exceptions could be thrown, in any number of places. This will not neccessarily happen on the open but most likely some part of the read. I was only curious if anyone had come up with a graceful and simple way of handling them all.
I agree. Here's the link:
subject: Database File Format
Similar Threads
java io
Creating a file by giving relative path
WA #1.....word association
performance issues with file read and write
Struts FormFile (parsing .csv files)