Data file Format
The format of data in the database file is as follows:
Start of file
4 byte numeric, magic cookie value identifies this as a data file
4 byte numeric, offset to start of record zero
2 byte numeric, number of fields in each record
Schema description section.
Repeated for each field in a record:
2 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
2 byte numeric, field length in bytes
end of repeating block
Data section. (offset into file equal to "offset to start of record zero" value)
Repeat to end of file:
2 byte flag. 00 implies valid record, 0x8000 implies deleted record
Record containing fields in order specified in schema section, no separators between fields, each field fixed length at maximum specified in schema information
End of file
All numeric values are stored in the header information use the formats of the DataInputStream and DataOutputStream classes. All text values, and all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field. The character encoding is 8 bit US ASCII.
Database schema
The database that Bodgitt and Scarper uses contains the following fields: Field descriptive name Database field name Field length Detailed description
Subcontractor Name name 32 The name of the subcontractor this record relates to.
City location 64 The locality in which this contractor works
Types of work performed specialties 64 Comma separated list of types of work this contractor can perform.
Number of staff in organization size 6 The number of workers available when this record is booked
Hourly charge rate 8 Charge per hour for the subcontractor. This field includes the currency symbol
Customer holding this record owner 8 The id value (an 8 digit number) of the customer who has booked this. Note that for this application, you should assume that customers and CSRs know their customer ids. The system you are writing does not interact with these numbers, rather it simply records them. If this field is all blanks, the record is available for sale.
Originally posted by Sun qinlong:
we can talk about this question each other .
ok?
keep in tuch !!!
Types of work performed specialties 64 Comma separated list of types of work this contractor can perform.
Number of staff in organization size 6 The number of workers available when this record is booked
Originally posted by Eugene Kononov:
It's not about flight reservation anymore?
Eugene.
Originally posted by Michael Dreese:
Eugene:
I think it is the new one. It comes with a version number. Mine is version 2.1.2.
Cheers,
Michael
Originally posted by Ta Ri Ki Sun:
bah, mines a few back then "Version 1.3.1"
Originally posted by Michael Dreese:
Dose yours come with the data file format?
Originally posted by Mark Spritzler:
I think they should also have one for booking a contractor or other home improvement company, that was the Beta exam.
Mark
What is the magic cookie value? Can I define it by myself? or I just use the one from the given db file?
According to the data file format, 2 byte flag 00 implies valid record, but the given db-2x2.db file uses 0001 instead. Am I getting the idea of "2 byte flag 00" wrong? Can somebody clarify it for me?
Also, I need some explanation for the following sentence - "null terminated if less than the maximum length for the field. The character encoding is 8 bit US ASCII."
What is "null terminated"? Does that mean I have to append NULL if less than the max. length for the field?
Record containing fields in order specified in schema section, no separators between fields, each field fixed length at maximum specified in schema information
Do I have to do any setting for 8 bit US ASCII?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
My UBB tags aren't working for some reason - sorry for the hard to read answer
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
The magic number in the airline assignment it was 0xC0C0BABE - Is it the same?
According to the data file format, 2 byte flag 00 implies valid record, but the given db-2x2.db file uses 0001 instead. Am I getting the idea of "2 byte flag 00" wrong? Can somebody clarify it for me?
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
quote:
--------------------------------------------------------------------------------
Do I have to do any setting for 8 bit US ASCII?
--------------------------------------------------------------------------------
Normally you would be working with 16 bit chars, so you should be doing some conversion between the unicode representation and the 8 bit ascii representation.
Originally posted by Barry Gaunt:
I can confirm that there is 0x0001 in the supplied db-2x2.db file. The assignment text says that it should be a 2 byte flag, 00 (valid) or 0x8000 (deleted). Should I contact Sun about this discrepancy?
Originally posted by Michael Dreese:
Also, I need some explanation for the following sentence - "null terminated if less than the maximum length for the field. The character encoding is 8 bit US ASCII."
What is "null terminated"? Does that mean I have to append NULL if less than the max. length for the field?
Do I have to do any setting for 8 bit US ASCII?
Originally posted by Werner Joerling:
Termination
In my db.db-file the fields are not terminated with a special character. They are simply filled with blanks. Is that another mistake in the db-file? (see the 00/01-flag-discussion)
It seems working fine. (Still with special characters beyond the 128 base characters.
Each character becomes one byte in the file. Maybe the instructions want to confuse here. Do I think wrong here?
Originally posted by Michael Dreese:
I don't quite get what you mean here. Would you mind to explain a bit more to me?
Originally posted by Werner Joerling:
What I mean is that as long as I only use characters from the 8-bit-US-ASCII charset there is nothing more to do than putting the Strings as byte-arrays to the file. In this case I do not need any conversions betweeen 8- and 16-bit-characters.
i byte flag. 00 implies valid record, 0xFF implies deleted record.
Originally posted by Erik Manor:
00 is octal for 0 (1 byte), 0xFF is hex for 255. Since byte is signed 255 does not fit in a byte without a cast. With a cast 255 is -1.
Don't get me started about those stupid light bulbs. |