File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S - find criteria Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S - find criteria " Watch "B&S - find criteria " New topic

B&S - find criteria

woo sung

Joined: Dec 09, 2005
Posts: 6
I want to make sure about discussion "B&S - serching" below.
I am doing B&S 2.1.1.

I have
"public int[] find(String[] criteria)."

And I have a sentese in The User Interface specification:
"It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user."

In the DB schema, name is first field and location is second field.

Therefore, can i call find method like :
String[] criteria = new String[];

int[] returnResult = DBImp.find(criteria);

and result will have int array of record numbers matching the value in name field( i.e both of "fred" and "freddy") and/or match the value in location (i.e both of "adel" and "adelaide")

Am i right?

another question is about "AND/OR" in "where the name AND/OR location fields exactly match values specified by the user."

I have no idea how i can make code "name and location" and "name or location".
if i pass the criteria array value below

String[] criteria = new String[];
criteria[2]="and"; or criteria[2]="or";

do you think it will be fine?

Joined: Oct 28, 2005
Posts: 26
In my program, I use the following:

Name only:
criteria[0] = "fred";
criteria[1] = ""; (Any in my GUI)

Location only:
criteria[0] = ""; (Any in my GUI)
criteria[1] = "atlantis";

Name & Location:
criteria[0] = "fred";
criteria[1] = "atlantis";

each values use for one column. First value for first column, ... null values will return all records.

Macy Wong<br />SCJP 1.4 & 5.0, SCJD, SCWCD, SCBCD, Oracle PL/SQL OCA
I agree. Here's the link:
subject: B&S - find criteria
It's not a secret anymore!