It's not a secret anymore!*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes getRecord Vs readRecord usage in criteriaFind() 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 "getRecord Vs readRecord usage in criteriaFind()" Watch "getRecord Vs readRecord usage in criteriaFind()" New topic
Author

getRecord Vs readRecord usage in criteriaFind()

Panku Panchal
Ranch Hand

Joined: Apr 24, 2003
Posts: 33
Hi,
I'm right now planning to write criteriaFind() method and I find getRecord() and readRecord() both methods useful. Can anybody tell me why I should use getRecord() or readRecord().
Which will be efficient and easy to code?
How can I make use of find() method?
Please do comment on this.
Panku
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11405
    
  81

Hi Panku,
I'm right now planning to write criteriaFind() method and I find getRecord() and readRecord() both methods useful. Can anybody tell me why I should use getRecord() or readRecord().

Have a think about what criteriaFind() returns and what readRecord() and getRecord() returns - can you see any simplification of your code if you use one versus the other?
How can I make use of find() method?

You may not have to use this for your criteriaFind - I certainly didnt.
But I did use it elsewhere in my program.
Regards, Andrew
[ April 29, 2003: Message edited by: Andrew Monkhouse ]

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

getRecord calls readRecord.
Look at the implementation of these two methods and see if you can see what the difference is between them. clue: Look at the signature, and why would getRecord call readRecord. What are the purposes of these methods?
use getRecord by the way.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Panku Panchal
Ranch Hand

Joined: Apr 24, 2003
Posts: 33
Ooops....Mark I overlooked it!!!
My mistake!
Andrew..thank you for the reply....I understood.
I want to know more about criteriaFind....am I suppose to find the best possible route for the user or just all available routes? What I mean do I need to sort the result considering distance, time etc.?
Also right now I'm thinking of taking command line input for testing my criteriaFind...also my parsing method works for input like
1."Carrier='SpeedySAir',Origin='SFO'"
2. Carrier=SpeedyAir, Origin=SFO
3. Carrier=SpeedyAir Origin=SFO
I want to know is there any restriction for user input format ? or do I have to restrict user from not using quotes and commas in search?
When I'll start working on GUI, I'll accept input in textbox or etc...then when will I use this kind of input?
1."Carrier='SpeedySAir',Origin='SFO'"
I'm really confused....
Please do help me in this method.
Panku
Panku Panchal
Ranch Hand

Joined: Apr 24, 2003
Posts: 33
One more thing about db.db field names ,
those doesn't match with search criteria provided by sun.For example I've db.db files with field names Origin airport values, Destination airport values and carrier values.
I;m trying to match thses fieldnames with my index/values pairs created by search criteria
"Carrier='SpeedyAir', Origin='SFO'"
It doesm't match and returns me garbage values.
How should be my search criteria and parsing method?
Do comment on this ....
Panku
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

In my submission I did not use the quotes around the value. Also you will want to use JComboBoxes for the user to select their criteria. Do not give them Textboxes to enter values as you will lose points if you do.
The search will bring in all records that match the criteria, no logic for the shortest route needed. Just the matching records.
Mark
Panku Panchal
Ranch Hand

Joined: Apr 24, 2003
Posts: 33
Hi Mark,
Ok...got some idea. So I have to bulid String criteria myself right? So can I consider complete fieldname as stored in db.db? Like my second post...
One more thing about db.db field names ,
those doesn't match with search criteria provided by sun.For example I've db.db files with field names Origin airport values, Destination airport values and carrier values.
I;m trying to match thses fieldnames with my index/values pairs created by search criteria
"Carrier='SpeedyAir', Origin='SFO'"
It doesm't match and returns me garbage values.
How should be my search criteria and parsing method?
Do comment on this ....
Panku

so my criteria string will be
"origin airport value='SFO',destination airport value='NY'"
For the current code i have I can parse as many fieldNames as user can input with the above quotes and comms format. Is it valid...?
Panku
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11405
    
  81

Hi Panku,
about db.db field names , those doesn't match with search criteria provided by sun

I think this is situation normal.
Check your instructions, mine state:
In the event of an invalid field name being provided as part of the criteria the behavior of this method is the same as if no records matched correctly specified

So if someone called my code with the criteria given as an example by Sun, they would get back zero results.
As Mark suggested: use JComboBoxes to let the user choose the search values. Then build the search criteria string yourself. That way your column names will always match those in the database.
Regards, Andrew
Panku Panchal
Ranch Hand

Joined: Apr 24, 2003
Posts: 33
Thank You Andrew,
got the solution.
Will post more difficulties as they appear.
Panku
Arun Bommannavar
Ranch Hand

Joined: Jan 11, 2003
Posts: 53
Originally posted by Panku Panchal:

Also right now I'm thinking of taking command line input for testing my criteriaFind...also my parsing method works for input like
1."Carrier='SpeedySAir',Origin='SFO'"
2. Carrier=SpeedyAir, Origin=SFO
3. Carrier=SpeedyAir Origin=SFO
I want to know is there any restriction for user input format ? or do I have to restrict user from not using quotes and commas in search?

Panku


Panku,
My instructions say
"Criteria take the form of a comma separated list of ....."
So, the following would not be right
3. Carrier=SpeedyAir Origin=SFO
Regards
Arun
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getRecord Vs readRecord usage in criteriaFind()
 
Similar Threads
Changing Access Specifiers of Data class
deprecated String constructor
FBNS: Inherit from Data class and How to operate db.db
SCJD
Retrieval of record should be based on Key or Flight number ?.