aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes what is the magic cookie value? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "what is the magic cookie value?" Watch "what is the magic cookie value?" New topic
Author

what is the magic cookie value?

joel smither
Ranch Hand

Joined: Jan 01, 2005
Posts: 31
In my urlybird dev exam project, there is something called a "magic cookie" value in the database file.

What is the purpose fo this piece of information, am I exprected to do something with it programmatically?

Thanks in advance.
Eric Chang
Ranch Hand

Joined: Jan 27, 2004
Posts: 113
There is a previous thread about this here: http://www.coderanch.com/t/186578/java-developer-SCJD/certification/Verify-database-format

You might find it useful.
joel smither
Ranch Hand

Joined: Jan 01, 2005
Posts: 31
I'm still not clear on what should be done with this cookie value.

I get the impression from reading previous threads that the cookie value is used to determine that a file is valid database file or not.

So what should I do in my application? Does every valid database file use the SAME cookie? If so I guess I could check to make sure the file has the appropriate cookie value when I first open it up for access. Is this the right thing to do?
Eric Chang
Ranch Hand

Joined: Jan 27, 2004
Posts: 113
You can do whatever you want with it. There is no MUST to do anything with the cookie value. Some people (like me) have decided to hardcode it in and use it to verify a database file. I'm sure there are other people who chose not to do anything with it (I was about to do that, but I figured one line of extra code couldn't hurt).
Sean Gildea
Ranch Hand

Joined: Jul 01, 2004
Posts: 81
I just verified it was equal to 00 00 in hex , since those are the first 2 hex numbers in the file.




SCJD, SCBCD, SCJP
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11278
    
  59

Hi everyone,

If you are not already aware of this, there are multiple assignments, and multiple versions of the assignments. Some of the variations in the versions of the assignments do include changes to the database structure. For example, some databases have a two-byte "deleted" flag, while others have a single-byte "deleted" flag. There are many more differences as well.

So even if two candidates are working on the contractors assignment, the database formats may be completely different. In such a case, though, the cookie values will be different.

I personally feel that you must validate the cookie value, as not all the database structural changes will be catered for in the meta data.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is the magic cookie value?
 
Similar Threads
non-networked and network mode
URLyBird: Read data file
Using and accessing variables, constants, and Magic Cookie.
What is the magic cookie used for?
magic cookie value?