• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Problem with the query in JDBC ,resultset empty

Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using chkUser() to check the user's existence in the database.
its also trying to fetch and set all the values for student eg email,phone while fetching the username and password...in both rs1 and rs2 if i set query with just UNAME = 'CHIRAG' then its giving me the result but
it doesn't give me reuslt with UNAME='CHIRAG' AND PASSWORD='chirag'...Is it that it doesn't support AND keyword..... with both UNAME and PASSWORD its giving me following output.....there is one row in database that has UNAME='CHIRAG' and Pasword='chirag' but it gives me rs empty ...not null

I am getting output

errorcode -1
at last errorcode -1

Following code.....
i am calling chkuser() which calls getStudentInfo()

[edited to add code tags]
[ April 12, 2005: Message edited by: Jeanne Boyarsky ]
author & internet detective
Posts: 40211
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you doing the query in two steps instead of one?

In any event, try the following query:
ResultSet rs1=stmt.executeQuery("SELECT SID, UNAME, PASSWORD FROM STUDENT WHERE UNAME like '%C%' AND PASSWORD like '%c%'");
This will help narrow down whether there is a typo. The "and" is very straightforward and not the problem. Also, note that the username and password values are case sensitive, so double check that.

Finally, note that the result set will never be null. JDBC drivers return an empty resultset, but not null. So that piece of code is extraneous.
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic