a JDBC question

Discussion in 'Java' started by Jerry, May 27, 2005.

  1. Jerry

    Jerry Guest

    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!
     
    Jerry, May 27, 2005
    #1
    1. Advertising

  2. Jerry

    Malte Guest

    Jerry wrote:
    > 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.
     
    Malte, May 27, 2005
    #2
    1. Advertising

  3. Jerry

    jonck Guest

    > If you make a call to the database.

    > If you cannot find any person with a matching last name


    This will give you an empty ResultSet.
     
    jonck, May 27, 2005
    #3
  4. > 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
     
    Niels Dybdahl, May 27, 2005
    #4
  5. Jerry

    Lucy Guest

    "Niels Dybdahl" <> wrote in message
    news:4296e78b$0$339$...
    > > 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


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

    mysql> select * from jones where i>5;
    Empty set (0.06 sec)
     
    Lucy, May 27, 2005
    #5
  6. Jerry

    Bob Guest

    Lucy wrote:

    > 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.)
    --
    Bob
     
    Bob, May 27, 2005
    #6
  7. Jerry

    steve Guest

    On Fri, 27 May 2005 17:06:41 +0800, jonck wrote
    (in article <>):

    >> If you make a call to the database.

    >
    >> If you cannot find any person with a matching last name

    >
    > This will give you an empty ResultSet.
    >


    how do you know he is using a result set?
     
    steve, May 28, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keith Wansbrough

    Re: jdbc help:sun.jdbc.odbc.JdbcOdbcDriver

    Keith Wansbrough, Aug 16, 2004, in forum: Java
    Replies:
    0
    Views:
    781
    Keith Wansbrough
    Aug 16, 2004
  2. Betty
    Replies:
    1
    Views:
    9,901
    Juha Laiho
    May 21, 2005
  3. Jesus M. Salvo Jr.
    Replies:
    2
    Views:
    4,304
    robert
    Feb 11, 2006
  4. Bruce
    Replies:
    4
    Views:
    780
    Bjorn Abelli
    Mar 25, 2006
  5. Lew
    Replies:
    0
    Views:
    536
Loading...

Share This Page