jQuery in Action, 3rd edition
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes still stuck in database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "still stuck in database" Watch "still stuck in database" New topic

still stuck in database

uzma ali
Ranch Hand

Joined: Jun 22, 2007
Posts: 56
I have got little idea and started getting database but still don't get the full desired result.

The description in the assignment is
Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
2 byte numeric, number of fields in each record

Schema description section.
Repeated for each field in a record:
1 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
1 byte numeric, field length in bytes
end of repeating block

Data section.
Repeat to end of file:
1 byte flag. 00 implies valid record, 0xFF 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

while I coded as under:

1)I am getting the feilds name but then values are somehow not fine.

2)Is it good to have only feild names first and then actuall values later altogether.

3)I am reading it using in.readInt which gives me cookie value but then I am using in.readByte. just concern that as in file discription it says "2 byte numeric, number of fields in each record " so isn't it htat I should use in.readShort...I tried but that does not work as it it eats up field name (instead of 'name' I can see 'ame' in the output)

Can anybody help, I would really appreciate it


Jason Moors
Ranch Hand

Joined: Dec 04, 2001
Posts: 188
Hi Uzma,

I think your problem is that your for loop is reading a byte, not sure why you are doing this??

You should be looping based upon the number of fields. i.e.

[ August 08, 2007: Message edited by: Jason Moors ]
uzma ali
Ranch Hand

Joined: Jun 22, 2007
Posts: 56
Thanks Jason

but when I use readShort I get

Field Name = [ame location@specialties@sizerateowner

see the field 'ame' instead of 'name' and other blocks

Can you suggest??


uzma ali
Ranch Hand

Joined: Jun 22, 2007
Posts: 56
thanks Jason
I was reading the byte twice I fixed it and appreciae your help


I agree. Here's the link: http://aspose.com/file-tools
subject: still stuck in database
It's not a secret anymore!