This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Records" Watch "Records" New topic
Author

Records

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.

Frans.

* 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!


SCJP 1.4, SCJD
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


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: http://aspose.com/file-tools
 
subject: Records
 
Similar Threads
(nx)About test:
my locking scheme
Customer and Customer activity file
Delete & Update
Whole Database lock question?