This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes rs.next() not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "rs.next() not working" Watch "rs.next() not working" New topic
Author

rs.next() not working

ALaxmi Shankaran
Greenhorn

Joined: Feb 23, 2004
Posts: 26
when i use any simple query like
select quantity from purchaseorder where ponumber=somenumber
then if record is not present then it returns false for if(rs.next()) which is correct
but when i am using the query as
select max(quantity) from purchaseorder where ponumber=somenumber
then even though no records presents then also returns true for if(rs.next()) why it is so?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

SQL functions always return something (even if that something is null). So select quantity from an empty table will give you an empty resultset, but select Max(quantity) from the same table will give you a result set with one row containing the result of the max() function (which might be 0, might be empty or might be "null" depending on your DB).


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: rs.next() not working
 
Similar Threads
ResultSet Thru ResultSet
Distinct select giving a problem
SQL commands in MS-Access....Pls Help
Using preparedStatement containing Oracle's to_date
java .lang .Number Format Error