• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

still stuck in database

 
uzma ali
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

regards

Uzma
 
Jason Moors
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



Regards
Jason
[ August 08, 2007: Message edited by: Jason Moors ]
 
uzma ali
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??

Appreciate

Uzma
 
uzma ali
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Jason
I was reading the byte twice I fixed it and appreciae your help

regards

Uzma
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic