Results 1 to 4 of 4

Thread: help needed

  1. #1
    Join Date
    Jan 2010
    Posts
    72
    Rep Power
    0

    Default help needed

    how to check for resultset when the query executed results nothing

    eg.
    if usename is blah
    and query made is
    select * from table where username='blahblah'
    this query will show 0 results
    what will be stored in the resultset at that time....
    i want to made a check in this case...

  2. #2
    andy16 is offline Member
    Join Date
    May 2010
    Posts
    11
    Rep Power
    0

    Default

    Java Code:
    if (myResultSet.next()) {
        // ResultSet is not empty (the user was found); write code here
    }
    
    else {
        // Your ResultSet is empty (no user with the given username was found)
    }
    The next() method on your ResultSet object returns true if there is another row in your ResultSet. Since you have not started looping through it, this is the same as checking whether it is empty or not (that is, checking if there is a first row).

    Also, make sure that your username column is unique.
    Last edited by andy16; 05-29-2010 at 11:20 AM.

  3. #3
    Join Date
    Jan 2010
    Posts
    72
    Rep Power
    0

    Smile

    Thanx a lot

  4. #4
    wzq110120 is offline Member
    Join Date
    May 2010
    Location
    china
    Posts
    7
    Rep Power
    0

Similar Threads

  1. Help Needed Please
    By ajaxjagadish in forum Advanced Java
    Replies: 1
    Last Post: 02-12-2010, 07:25 PM
  2. Help Needed
    By jyothi_tallapaneni in forum Advanced Java
    Replies: 1
    Last Post: 02-11-2010, 07:07 PM
  3. Help needed
    By harshalsakpal in forum CLDC and MIDP
    Replies: 0
    Last Post: 02-17-2009, 03:53 PM
  4. help needed
    By amarchandar in forum New To Java
    Replies: 3
    Last Post: 02-17-2009, 01:59 PM
  5. help needed.
    By dirtycash in forum New To Java
    Replies: 3
    Last Post: 12-03-2007, 09:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •