aspose file tools*
The moose likes JDBC and the fly likes ResultSet object returning null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ResultSet object returning null" Watch "ResultSet object returning null" New topic
Author

ResultSet object returning null

Arpit Panwar
Greenhorn

Joined: Jul 16, 2009
Posts: 12


where ResultSet is defined in class as

conct is a valid connection object
and query is also valid and the table also has rows in it...still resultset keeps fetching null....Can anyone help..


SCJP 75%
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2499
    
    8

What happens to a ResultSet when you close its connection?
You close the connection. Then you return the resultset.

keeps fetching null
What does that mean: no rows? rs == null ?

OCUP UML fundamental and ITIL foundation
youtube channel
Arpit Panwar
Greenhorn

Joined: Jul 16, 2009
Posts: 12
Yup ResultSet returns no rows

ResultSet.getFetchSize() returns 0 i.e. no rows are being fetched

And should closing the Connection have anything to do with ResultSet object???
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2499
    
    8

Arpit Panwar wrote:

And should closing the Connection have anything to do with ResultSet object???
Yes.
You can think of a resultset as a cursor into the database. The connection is needed to navigate to the next record.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2499
    
    8

Arpit Panwar wrote:Yup ResultSet returns no rows

ResultSet.getFetchSize() returns 0 i.e. no rows are being fetched
This method might not do what you expect that it does:
http://www.coderanch.com/t/299924/JDBC/java/workings-ResultSet-getFetchSize
Arpit Panwar
Greenhorn

Joined: Jul 16, 2009
Posts: 12
I tried it without closing the connection the result is the same....
Still i keep Getting 0 rows
has is something to do with my Connection
Arpit Panwar
Greenhorn

Joined: Jul 16, 2009
Posts: 12
Jan Cumps wrote:
Arpit Panwar wrote:Yup ResultSet returns no rows

ResultSet.getFetchSize() returns 0 i.e. no rows are being fetched
This method might not do what you expect that it does:
http://www.coderanch.com/t/299924/JDBC/java/workings-ResultSet-getFetchSize


Ok Thanks
Il try it out right away
Arpit Panwar
Greenhorn

Joined: Jul 16, 2009
Posts: 12
Thanks
It Really Helped
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2499
    
    8

Ah. Good!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ResultSet object returning null