a JDBC question

J

Jerry

If you make a call to the database.

If you cannot find any person with a matching last name, do you

a. Return null

b. Throw a RuntimeException

c. Other (what will you do?)

Thanks a lot!
 
M

Malte

Jerry said:
If you make a call to the database.

If you cannot find any person with a matching last name, do you

a. Return null

b. Throw a RuntimeException

c. Other (what will you do?)

Thanks a lot!

Why don't you just airmail me the whole questions form and I will answer
all your homework questions for you at only 100 USD an hour.
 
N

Niels Dybdahl

If you make a call to the database.
If you cannot find any person with a matching last name, do you

a. Return null
b. Throw a RuntimeException
c. Other (what will you do?)

Depends upon the task. If the person should be in the database I would use
b. If it is likely that the person is not in the database then I would use
a.

a will allow the execution to continue allowing the application to create
the person in the database.
b will jump out of the execution to an exception handler, that will
typically show a message to the user why the operation failed.

Niels Dybdahl
 
L

Lucy

Niels Dybdahl said:
Depends upon the task. If the person should be in the database I would use
b. If it is likely that the person is not in the database then I would use
a.

a will allow the execution to continue allowing the application to create
the person in the database.
b will jump out of the execution to an exception handler, that will
typically show a message to the user why the operation failed.

Niels Dybdahl

Here is what mysql does, why would you do something different.

mysql> select * from jones where i>5;
Empty set (0.06 sec)
 
B

Bob

Lucy said:
Here is what mysql does, why would you do something different.

mysql> select * from jones where i>5;
Empty set (0.06 sec)

I assume the question refers to how your code would handle the fact that
there were no results in the ResultSet (detected when ResultSet.first()
returns false).

And I think it really depends on the context of the code.

If it's a job interview question, then probably the only answer is: it's
not what you answer, it's how you answer.

(I've read that even wrong answers delivered thoughtfully will impress
an interviewer, whereas a right answer delievered quickly and without
thought will turn off the interviewers. For the record, I hate job
interviewers.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top