wood burning stoves 2.0*
The moose likes JDBC and the fly likes resultset next() returns false and yet record(s) exist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "resultset next() returns false and yet record(s) exist" Watch "resultset next() returns false and yet record(s) exist" New topic
Author

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

Zeko Mbumwae
Greenhorn

Joined: Aug 08, 2009
Posts: 12
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30361
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Zeko Mbumwae
Greenhorn

Joined: Aug 08, 2009
Posts: 12

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

Joined: Dec 20, 2006
Posts: 2497
    
    8

You have already called res.next() in line 21 before starting the while loop.

Regards, Jan


OCUP UML fundamental and ITIL foundation
youtube channel
Zeko Mbumwae
Greenhorn

Joined: Aug 08, 2009
Posts: 12
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: resultset next() returns false and yet record(s) exist