This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DBAccess interface question

 
Kevin Mc Cusker
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I intended to take this almost 12 months ago but have only got the time (and motivation) to do it now!?!
Anyway, i am looking at the DBAccess interface, to be implemented by Data.java.
What i wanted to start with is simply reading the records from my .db file and display on my GUI. Now, two functions have caught my attention,:

//reads a record from the file. returns array each element is a record value
public String [] readRecord(long recNo)
throws RecordNotFoundException;

and

//returns array of record numbers that match criteria fieled
//n in database file is described by criteria[n]
public long[] findByCriteria(String [] data);

My intention was first to query the file for records, and adding each match to my local database, each of which is displayed on my gui.

Anyway am I correct in assuming that in order to get a list of records, I must first call findByCriteria to get the recordnumber (im positive the file does not have this recordnumber) of the matching record and then call readRecord using this recordnumber?

looking at this and taking into cosideration locking records etc, perhaps the best option is a database at the server (which includes record numbers), persisting any changes to disk.

But the comments provided by sun seem to dictate that i cant do this, "reads a record from the file".

Please help me determine what suns comments do\dont allow me to do and what the two functions may be for.
 
Kevin Mc Cusker
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers Anton,
I have just realised that a deleted record doesnt affect any of the other records' positions, so no need for a record number there. So perhaps with each search of each record in the database file I could record what number i was at and use that as the record number.

I was thinking of perhaps checking the delete value with the readRecord function, ignoring the record if its been blown away.

Strange why this all couldnt be done with one pass though.
 
Anton Golovin
Ranch Hand
Posts: 527
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kevin Mc Cusker:
Cheers Anton,
I have just realised that a deleted record doesnt affect any of the other records' positions, so no need for a record number there. So perhaps with each search of each record in the database file I could record what number i was at and use that as the record number.

I was thinking of perhaps checking the delete value with the readRecord function, ignoring the record if its been blown away.

Strange why this all couldnt be done with one pass though.


Hi, Kevin. Sorry, I posted, but then I deleted the post. What is the name of your assignment, if I may ask; there are different approaches to different ones.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic