Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about unique identity of record and lock

 
LianGuang Wang
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
// Reads a record from the file. Returns an array where each
// element is a record value.
public String[] read(int recNo) throws RecordNotFoundException;
what's the meaning of recNo?i think that is the position in the physical file.so it's not unique because this recNo can be reused.
so in the update synchronized block,we need to compare each field in the record to confirm the record state.and the client must send back all the field of the record which be booked?
It's truth? i want a Positive response! thanks!
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11855
187
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "Hot Strong"

Welcome to JavaRanch and this forum.

We don't have many rules here, but one we do have is the JavaRanch Official policy on registered names which requires the display name to be a real name. Please read this policy document and change your display name to meet the requirements. You can change your display name here.

Thanks, Andrew
 
LianGuang Wang
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm sorry for my inattention!
 
Animesh Saxena
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't understand ur question clearly.
recNo is just a number which indicates position of record. to get the actual record you use something like this

dbFile.seek((recNo-1) * recordLength);
keep the recordLength calculated in the beginning only.
assuming recNo starts from 1...
in update method when you pass the recNo seek the location of file using the above code and write the content in form of bytes.
if its a string then use.
dbFile.write(contentString.getBytes());
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic