Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

JDBC question

Thread view: 
shaji - 21 Dec 2005 07:17 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.