File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Records 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 "Records" Watch "Records" New topic


Kris Reid
Ranch Hand

Joined: Jan 05, 2005
Posts: 247
With the URLyBird

What are record numbers? They are just the records position in a file right.

so when a record gets marked as deletes (say record 5) do all the following recods move down one spot? (record 6 becomes 5). Then when a new record is added and gets written to the spot the last was deleted, is the new record number 5?

Is it ok to have a collections of type record? A record object just holds strings of all the fields. When the data file is opened I have it filling up the Collection with all the records. Then read just spits out the correct one. Update() updates the Collection and the file
Frans Janssen
Ranch Hand

Joined: Dec 29, 2004
Posts: 357
Hi Kris,

I have the Bodgitt and Scarper assignment and my instructions specify that each record has the following flag:
2 byte flag. 00 implies valid record, 0x8000 implies deleted record

I have interpreted just as you that the record number is just the position of the record in the file. I also count deleted records, so if a record is deleted, it keeps the same number.*

For example, the database could have the following contents:

0 - record A
1 - record B
2 - record C [deleted]
3 - record D

If a clients attempts to read or lock record 2, the server throws a RecordNotFoundException.


* I think this has to be. Imagine in my example if one client attempts to access record #3, just after another client deletes record #1. Then record #3 would have been renumbered to #2 and the first client would get an exception. Not quite a practical approach!

Clivant Yeo
Ranch Hand

Joined: May 22, 2004
Posts: 124
I used the starting position of the record at the file as the record number. Reading the record again is easier by just having to seek the start position using the record number. Hope it helps

With regards,

Clivant Yeo
My Personal Website
Eric Chang
Ranch Hand

Joined: Jan 27, 2004
Posts: 113
In my assignment, there were no record numbers at all in the database file, so I ended up assigning them upon the startup of the application to whatever order they were read in.
I agree. Here's the link:
subject: Records
It's not a secret anymore!