hi,
Is it a good practice to pass java.sql.ResultSet as a parameter?
method A(){
//creating db conn and getting resultset.
......
ResultSet rs = stmt.executeQuery(query);
List myObjects = B(rs);
......
}
method B(ResultSet rs){
//do processing with rs.
return myObjects;
}
Is this a good practice?
Viator - 21 Dec 2005 07:39 GMT
Why do you see a problem in that??
Roedy Green - 21 Dec 2005 11:02 GMT
>Is this a good practice?
Why wouldn't it be?

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
linc - 21 Dec 2005 22:57 GMT
>>Is this a good practice?
>
> Why wouldn't it be?
Just be sure that by the time you get to your evaluation of rs, there's
no way rs.close has already happened.
I did that to myself last week.
Linc
Tim Terry - 22 Dec 2005 00:21 GMT
> hi,
>
[quoted text clipped - 14 lines]
>
> Is this a good practice?
i would only like to reference an instance of a resultset in my data
layer. as long as this is the case its fine.
Tim
Rob Mitchell - 23 Dec 2005 17:51 GMT
"shaji" <shaji.cc@gmail.com> wrote in news:1135149471.030002.63100
@g47g2000cwa.googlegroups.com:
> hi,
>
[quoted text clipped - 14 lines]
>
> Is this a good practice?
Just make sure you call rs.close(); as well as the DataSource Connection
object.
Rob
Rob Mitchell - 23 Dec 2005 17:51 GMT
[posted and mailed]
"shaji" <shaji.cc@gmail.com> wrote in news:1135149471.030002.63100
@g47g2000cwa.googlegroups.com:
> hi,
>
[quoted text clipped - 14 lines]
>
> Is this a good practice?
Just make sure you call rs.close(); as well as the DataSource Connection
object.
Rob
richardsosborn@gmail.com - 23 Dec 2005 17:58 GMT
you have to watch how far you pass this around. while it's "open"
(referenced and not closed) this connection to the database is left
open. it's bound to it. do not place this in session or pass up to
the presentation layer. bad idea.
> hi,
>
[quoted text clipped - 14 lines]
>
> Is this a good practice?
Rob Mitchell - 27 Jan 2006 03:24 GMT
[posted and mailed]
"shaji" <shaji.cc@gmail.com> wrote in news:1135149471.030002.63100
@g47g2000cwa.googlegroups.com:
> hi,
>
[quoted text clipped - 14 lines]
>
> Is this a good practice?
Sure, as long as your method B() is quick and either handles exceptions
and throws to caller and someone calls rs.close(); sometime. You don't
want to keep DataSource connection opened for a long time in web-based
applications since they're typically a shared resource.
Rob