wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes All numeric values are stored in the header information 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 "All numeric values are stored in the header information" Watch "All numeric values are stored in the header information" New topic
Author

All numeric values are stored in the header information

paul seldon
Greenhorn

Joined: Oct 26, 2006
Posts: 13
"Header Information"
Is it from the start of the file to right before schema section,
right? When I print *.db file it comes out like below :
------------------------------------------------------------------------
< Instruction.html >
-> Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
4 byte numeric, total overall length in bytes of each record
2 byte numeric, number of fields in each record

Schema description section.

------------------------------------------------------------------
< Result after reading dataInputStream>

Cookie value(4Byte) : 513
OveralLength(4Byte) : 183
NumberOfField(2Byte): 6

Each Record has :
name : 32
location : 64
specialties : 64
size : 6
rate : 8
owner : 8
Head Size : 70
----------------------------------------------------------------

70 means what? 70 byte for all header information?
How should I think of this?

Let me know. Thanks -
Benjamin Wang
Greenhorn

Joined: Sep 30, 2006
Posts: 5
yes

We have same magic cookie value and header length.
Keith Jones
Ranch Hand

Joined: Oct 30, 2006
Posts: 105
I wonder how you came to that cookie value. Mine is:

first byte: 0
second byte: 0
third byte: 2
forth byte: 3

I was also wondering if we have to check this value whenever reading the file. In other words do we have to say:

if (magicCookieValue equals "something") {
proceed
}
else {
error
}


SCJP 1.4
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi,

A small tip - uses a hex editor to peek in to the db file, you'll easily get your cookie.
The cookie purpose is to identify a valid database file, this because each database can have a different structure, by example in my scheme :

1 byte flag. 00 implies valid record, 0xFF implies deleted record


but I know other scheme with different values.

Regards M


SCJP, SCJD, SCWCD, OCPJBCD
Mark Smyth
Ranch Hand

Joined: Feb 04, 2004
Posts: 288
Originally posted by Keith Jones:
I wonder how you came to that cookie value. Mine is:

first byte: 0
second byte: 0
third byte: 2
forth byte: 3

I was also wondering if we have to check this value whenever reading the file. In other words do we have to say:

if (magicCookieValue equals "something") {
proceed
}
else {
error
}


You need to read the four bytes together as an integer value rather than as 4 consectutive bytes to get the magic cookie value. Use the readInt() method to do this.


SCJP<br />SCJD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: All numeric values are stored in the header information
 
Similar Threads
NX: Bodgitt and Scarper: what to do with the db-2*3.db file? write a parser? and...
NX : Help! Error occur in read the data file!
Please Comment on Data Section
About the db file question.
Data File Format & Schema File