wood burning stoves 2.0*
The moose likes JDBC and the fly likes can you pass ResultSet as argument Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "can you pass ResultSet as argument" Watch "can you pass ResultSet as argument" New topic
Author

can you pass ResultSet as argument

P. Ingle
Ranch Hand

Joined: Apr 25, 2005
Posts: 45
Hello,

Can you pass Resultset as an argument or input parameter to a method
Can you return ResultSet from a method?

Thanks,
P.Ingle


Thanks,<br />P.Ingle
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by p Ingle:

Can you pass Resultset as an argument or input parameter to a method


Yes


Can you return ResultSet from a method?


Yes, A method where you are executing your query you may return resultset


One point to be noted that an application has several role/operations and you can logically/physically seperate them as per their responsibility.
for example in MVC speration of responsibility are

controlling request
Selection of view
business logic layer

Similarly there is a layer in your application Data layer where you can say you are doing operations related to database. If your question related to data layer then it is ok.such operation should be limited to data layer, else instead of returning a resultset from a method you can return VOs or DTOs.

Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
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 class´┐Ża 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can you pass ResultSet as argument