Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

resultset next() returns false and yet record(s) exist

 
Zeko Mbumwae
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using oracle.jdbc.driver.OracleDriver (odbc14.jar with all oracle.dbtool plugins for eclipse installed).My resultset.next() returns false.
I alternatively tried to use OracleCachedRowSet but getRows() finds zero records too.My code is below
Please help am stuck on this.

Thanks.


 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 35977
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zeko,
Does "Select username,password AS num from mjzeko.users where username= ? AND password= ?" return any rows if you run it at the commandline? If so, double check the username/password are the same case as in the database and don't contain any extra whitespace.
 
Zeko Mbumwae
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The SQL Statement is OK and returns rows...Even just SELECT * FROM USERS will not make res.next() return true.

Thanks for the reply....Help!
 
Jan Cumps
Bartender
Posts: 2618
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have already called res.next() in line 21 before starting the while loop.

Regards, Jan
 
Zeko Mbumwae
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jan,
Thanks for the reply and noticing that unnecessary res.next(). Looks like it was the culprit.After so many issues I changed my code as below.It works well now.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!