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

problem with DBAccess readRecord method

 
xi brian
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
in the DBAccess interface, the method called"

public String[] readRecord(long recNo) throws RecordNotFoundException;"

1. why there is a long as argument?
i believe that i could just use datainputstream to read the data from the data.db file.
please explain a little bit here.

2. for the return string[], isn't it supposed to contain all the info of the db file, or just one feild of the info.

thank you
 
Anne Crace
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brian,
for the long recNo, you are going to have to figure out how to handle it. A counting/iterating mechanism perhaps. I have a Map with the recNo as the key and an ArrayList of Strings with the rest of record as the value. The String[] is the individual record (all of the fields of one record). I have 29 records in my file, and 7 fields in each record, without the record number, because you have to deal with that on your own. It isn't already there. Hope that helps. I had trouble with that particular aspect of the project myself.
 
xi brian
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your help

i kind of getting what i suppose to do here
 
xi brian
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am done with readRecord part,but still a little confused

why readRecord method take an long as an argument, instead of an int ??
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic