Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Could resultset be returned from another method?

 
Ziyang Zhang
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a utility class to get resultset:

So that in other class, I can invoke this method to get resultset:


But this does not work, I get SQLException if I invoke next() method on the returned resultset.

I searched the reason, and i think this may be the reason:
Or you can look at CachedRowSet, because ResultSet object is bound with the Statement object. However, CacheRowset is independent and made for passing across layers.

JDBC Tutorail says:

A CachedRowSet classa disconnected rowset that caches its data in memory; not suitable for very large data sets, but an ideal way to provide thin Java clients, such as a Personal Digital Assistant (PDA) or Network Computer (NC), with tabular data


Could somebody explain more to me?
Thanks a lot,
Ziyang
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A ResultSet can certainly be returned from a method, but if you close the connection, then all associated resources (ResultSets, Statements, etc.) will be closed as well.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic