This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "question about recNo" Watch "question about recNo" New topic
Author

question about recNo

Jofer Chan
Ranch Hand

Joined: Sep 09, 2003
Posts: 49
Hi,Philippe:
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
Bartender

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.
    Best,
    Phil.
    [ October 24, 2003: Message edited by: Philippe Maquet ]
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
     
    subject: question about recNo
     
    Similar Threads
    CPU cicles in lock method
    DAO or Service?
    displaying recNo in gui
    my question about LockManager.java
    RecordNotFoundException