Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database file Validation

 
Diarmuid McDonald
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I have a dilema regarding the Database file. IN the requiremenst it specifies that a

"4 byte numeric, magic cookie value. Identifies this is a data file."

Should I have any validation when loading up the database file.

e.g. If its not numeric, dont start up back end database.
 
Ronald Wouters
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Diamuid,

when I start my server and say the database file is not there, empty (zero bytes), or for some reason an error occurs reading in the db schema, the end user gets a popup window saying "Fatal error occurred - shutdown in progress".
The user can do nothing but click ok and the system shuts down.
The logfile will show something like "bad magic number".

Regards,
Ronald.
 
Eiji Seki
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So do I. I just read the 4 bytes, expecting that there are all there, indeed.
Notice that your question is a bit strange, since they are 4 BYTES, so they will always be numeric if you want them to.
 
Jason Moors
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you want to go further than just checking that the magicCookie is numeric.

The magicCookie value is the identifier that indicates the file is a valid data file, therefore I determined the actual value (in my db-1x1.db file) and created a constant which use to validate against.

i.e


For the actual error handling I did the same as Ronald and Eiji.

regards

Jason
[ March 09, 2006: Message edited by: Jason Moors ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic