passing a method a resultset

Is there any reasons I should definately not pass result sets into other methods ? I am properly closing the methods, but I wasn't sure if passing around resultsets is an acceptable practice. thanks in advance.
[225 byte] By [Aknibbsa] at [2007-11-26 22:58:31]
# 1

It's kind of dodgy. If you pass the ResultSet to a method so it can suck out the data and store it in a list of objects, that's okay. If you pass the ResultSet to a method which stores a reference to it which will be used at some later time, that probably isn't okay. Basically you should rarely do anything with a ResultSet except to extract the data from it.

However it is possible to write code that uses scrollable ResultSets. In this case you might be displaying the data to the user and updating the database via the ResultSet. I would say that doing this in a single-user application, with a single connection that stays open for the life of the job, might be okay. But trying to put that logic into something like a web application is stretching the concept too far.

DrClapa at 2007-7-10 12:24:25 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

I am trying to figure out a way to decouple a rather lengthy little program. It has several resultsets that are all used at the same time to figure out what each other should be based on the results of some of the previous ones. I'm going to tinker with it and see if I can't at least find some of the result sets where I only require a single type of data instead of dozens of columns and strip those out. Thanks for the thoughts.

Aknibbsa at 2007-7-10 12:24:25 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

> I am trying to figure out a way to decouple a rather

> lengthy little program. It has several resultsets

> that are all used at the same time to figure out what

> each other should be based on the results of some of

> the previous ones.

Sounds like a join to me.

jschella at 2007-7-10 12:24:25 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...