Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

ResultSet object returning null

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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..
 
Bartender
Posts: 2658
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Arpit Panwar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2658
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 2658
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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:
https://coderanch.com/t/299924/JDBC/java/workings-ResultSet-getFetchSize
 
Arpit Panwar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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:
https://coderanch.com/t/299924/JDBC/java/workings-ResultSet-getFetchSize



Ok Thanks
Il try it out right away
 
Arpit Panwar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
It Really Helped
 
Jan Cumps
Bartender
Posts: 2658
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. Good!
 
We noticed he had no friends. So we gave him this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic