It's not a secret anymore!
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes question about recNo 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 "question about recNo" Watch "question about recNo" New topic

question about recNo

Jofer Chan
Ranch Hand

Joined: Sep 09, 2003
Posts: 49
In my DBAccess interface define follow:
public String [] readRecord(long recNo)
but in my DB file does not have the recNo,
How to get the recNo?
Is the recNo means a record's id?
if yes,but no fields(name,location,specialties,size,rate,owner) to storage it in the DB.
Philippe Maquet

Joined: Jun 02, 2003
Posts: 1872
Hi Jofer,
recNo is just a record number. The first one is numbered 0 (or possibly 1 or as you like - check your instructions). After having read the file header, you should know (directly or by computation) :
  • where the data section (the actual records) starts (dataSectionOffset below)
  • the length of each record

  • So, to read any record in the case your records are numbered starting with 1, you must read the file starting at position (dataSectionOffset + (recNo - 1) * recordLength), up to that position + recordLength.
    In the case your records numbers start with 0, the formula above becomes (dataSectionOffset + recNo * recordLength).
    How to get the recNo?

    Your application will get them as return values of your find() method.
    [ October 24, 2003: Message edited by: Philippe Maquet ]
    I agree. Here's the link:
    subject: question about recNo
    It's not a secret anymore!