It's not a secret anymore!
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes readRecord vs findByCriteria 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 "readRecord vs findByCriteria" Watch "readRecord vs findByCriteria" New topic

readRecord vs findByCriteria

Ed Green

Joined: Jun 15, 2004
Posts: 11
Hello all,
I'm doing B&S assignment, and have the following interface:


Maybe i'm missing something, but findByCriteria() returns a list of record numbers, which i can't return to the client, so i guess i'll have to do a readRecord() of all the records using that long[], but i've just physically read all of them to do the findByCriteria()!
Seems like a waste. What am i missing?
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
hi Ed:
public String [] readRecord(long recNo)

The readRecord(long recNo) method will come handy if a client knows which record to display. I use this method in delete and update. If a client attempt to delete record n, the client can display record n before deleting it, this way it ensures no records will be deleted by mistake.

SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
You could call readRecord in findByCriteria to get a record's data to compare to the criteria array.

Anthony W.<br />MCP, SCJP 1.4, SCJD, SCWCD 1.3, SCWCD 1.4, SCBCD
Ed Green

Joined: Jun 15, 2004
Posts: 11
Hi Hanna,
Tnx for the usage ideas, makes sense.

Thanx for the reply, i was thinking the same thing, but i don't know the exact record count, but i guess i could call read with an ever increasing number until i get EOF..
Hans Nemarich

Joined: Jun 10, 2004
Posts: 1
ED, you can try something like this to know how many records are:

I agree. Here's the link:
subject: readRecord vs findByCriteria
jQuery in Action, 3rd edition