• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

All numeric values are stored in the header information

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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 -
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes

We have same magic cookie value and header length.
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
}
 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
reply
    Bookmark Topic Watch Topic
  • New Topic