You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Shapira, Yoav" <Yo...@mpi.com> on 2003/10/01 14:43:57 UTC

[OFF-TOPIC] RE: can resultset object be re-used

Howdy,
First, this is off-topic and should be marked as such.

Second, the answer is no: you can't reuse them, it's one per query.  In
fact, since ResultSet is an interface, you don't even have a constructor
you can use (although you could always try to reflect the
implementation).

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Paul [mailto:paul@msci.ca]
>Sent: Tuesday, September 30, 2003 4:21 PM
>To: Tomcat Users List
>Subject: can resultset object be re-used
>
>jdbc question (tomcat 4.x, java 1.4.2, jdbc 3.0):
>
>can the ResultSet object be re-used to retrieve results from altogether
>different sql query in same .jsp page?  Or does a new ResultSet object
need
>to be created for each distinct sql query?
>
>-paul lomack.



This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged.  This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: [OFF-TOPIC] RE: can resultset object be re-used

Posted by Paul <pa...@msci.ca>.
thanks for response Yoav,

i knew message was off topic, but did not realize that such messages should
be marked such.  Thanks for informing me.

your answer to my question is what i would have guessed, but cannot find
anything to that effect in Java Docs on ResultSet interface.

to complicate the matter, i have some code as follows, which works fine
(which is why i posted question in first place, because i would have guessed
what you said):

for (i=0; i < parentTable.size(); i++) {

// note: this stmt executed repeatedly in for loop

rset4 = stmt.executeQuery ("select field1, field2, fieldN from
schema.tblsubj3 where field4 = " + parentTable.get(i) + " order by field1");

if (rset4.next()) {

....

Note that the ResultSet interface, rset4, is re-used repeatedly for changing
values in the array "parentTable", altering only the value for the WHERE
condition in each iteration of the loop.

notes:

rset4 is initialized outside the try-catch block as follows:
ResultSet rset4 = null;

the array parentTable is initialized as follows:

ArrayList parentTable = new ArrayList();

I am not asking a question this time round.   Just thought i would share
this info.  Also wondering if this use of ResultSet could generate
un-reliable results.

-paul.



----- Original Message ----- 
From: "Shapira, Yoav" <Yo...@mpi.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, October 01, 2003 8:43 AM
Subject: [OFF-TOPIC] RE: can resultset object be re-used


>
> Howdy,
> First, this is off-topic and should be marked as such.
>
> Second, the answer is no: you can't reuse them, it's one per query.  In
> fact, since ResultSet is an interface, you don't even have a constructor
> you can use (although you could always try to reflect the
> implementation).
>
> Yoav Shapira
> Millennium ChemInformatics
>
>
> >-----Original Message-----
> >From: Paul [mailto:paul@msci.ca]
> >Sent: Tuesday, September 30, 2003 4:21 PM
> >To: Tomcat Users List
> >Subject: can resultset object be re-used
> >
> >jdbc question (tomcat 4.x, java 1.4.2, jdbc 3.0):
> >
> >can the ResultSet object be re-used to retrieve results from altogether
> >different sql query in same .jsp page?  Or does a new ResultSet object
> need
> >to be created for each distinct sql query?
> >
> >-paul lomack.
>
>
>
> This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential, proprietary
and/or privileged.  This e-mail is intended only for the individual(s) to
whom it is addressed, and may not be saved, copied, printed, disclosed or
used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the
sender.  Thank you.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: [OFF-TOPIC] RE: can resultset object be re-used

Posted by Jan Agermose <ja...@agermose.dk>.
how is this reusig the resultset? you are reusing the statement but not the
resultset

Jan


----- Original Message ----- 
From: "Mike Curwen" <gb...@gb-im.com>
To: "'Tomcat Users List'" <to...@jakarta.apache.org>
Sent: Wednesday, October 01, 2003 3:58 PM
Subject: RE: [OFF-TOPIC] RE: can resultset object be re-used


> Well I just gotta say that's not true.  You *can* re-use a resultset
> object.
>
> ResultSet rs = st.executeQuery("SELECT * FROM FOO");
> //code that loops over rs and outputs results...
> rs = st.executeQuery("SELECT * FROM BAR");
> //a re-used ResultSet object.
>
>
> > -----Original Message-----
> > From: Shapira, Yoav [mailto:Yoav.Shapira@mpi.com]
> > Sent: Wednesday, October 01, 2003 7:44 AM
> > To: Tomcat Users List
> > Subject: [OFF-TOPIC] RE: can resultset object be re-used
> >
> >
> >
> > Howdy,
> > First, this is off-topic and should be marked as such.
> >
> > Second, the answer is no: you can't reuse them, it's one per
> > query.  In fact, since ResultSet is an interface, you don't
> > even have a constructor you can use (although you could
> > always try to reflect the implementation).
> >
> > Yoav Shapira
> > Millennium ChemInformatics
> >
> >
> > >-----Original Message-----
> > >From: Paul [mailto:paul@msci.ca]
> > >Sent: Tuesday, September 30, 2003 4:21 PM
> > >To: Tomcat Users List
> > >Subject: can resultset object be re-used
> > >
> > >jdbc question (tomcat 4.x, java 1.4.2, jdbc 3.0):
> > >
> > >can the ResultSet object be re-used to retrieve results from
> > altogether
> > >different sql query in same .jsp page?  Or does a new
> > ResultSet object
> > need
> > >to be created for each distinct sql query?
> > >
> > >-paul lomack.
> >
> >
> >
> > This e-mail, including any attachments, is a confidential
> > business communication, and may contain information that is
> > confidential, proprietary and/or privileged.  This e-mail is
> > intended only for the individual(s) to whom it is addressed,
> > and may not be saved, copied, printed, disclosed or used by
> > anyone else.  If you are not the(an) intended recipient,
> > please immediately delete this e-mail from your computer
> > system and notify the sender.  Thank you.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: [OFF-TOPIC] RE: can resultset object be re-used

Posted by Nikola Milutinovic <Ni...@ev.co.yu>.
> Well I just gotta say that's not true.  You *can* re-use a resultset
> object.
>
> ResultSet rs = st.executeQuery("SELECT * FROM FOO");
> //code that loops over rs and outputs results...
> rs = st.executeQuery("SELECT * FROM BAR");
> //a re-used ResultSet object.

You're not re-using anything here, pal!

"Statement.executeQuery( String query )" *creates* a ResultSet object. What
you've done is create TWO ResultSet object. The first will be "lost" and
caught by the garbage collector (in C++ this would cause memory leak).

Nix.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: [OFF-TOPIC] RE: can resultset object be re-used

Posted by Mike Curwen <gb...@gb-im.com>.
Well I just gotta say that's not true.  You *can* re-use a resultset
object. 

ResultSet rs = st.executeQuery("SELECT * FROM FOO");
//code that loops over rs and outputs results...
rs = st.executeQuery("SELECT * FROM BAR");
//a re-used ResultSet object.


> -----Original Message-----
> From: Shapira, Yoav [mailto:Yoav.Shapira@mpi.com] 
> Sent: Wednesday, October 01, 2003 7:44 AM
> To: Tomcat Users List
> Subject: [OFF-TOPIC] RE: can resultset object be re-used
> 
> 
> 
> Howdy,
> First, this is off-topic and should be marked as such.
> 
> Second, the answer is no: you can't reuse them, it's one per 
> query.  In fact, since ResultSet is an interface, you don't 
> even have a constructor you can use (although you could 
> always try to reflect the implementation).
> 
> Yoav Shapira
> Millennium ChemInformatics
> 
> 
> >-----Original Message-----
> >From: Paul [mailto:paul@msci.ca]
> >Sent: Tuesday, September 30, 2003 4:21 PM
> >To: Tomcat Users List
> >Subject: can resultset object be re-used
> >
> >jdbc question (tomcat 4.x, java 1.4.2, jdbc 3.0):
> >
> >can the ResultSet object be re-used to retrieve results from 
> altogether 
> >different sql query in same .jsp page?  Or does a new 
> ResultSet object
> need
> >to be created for each distinct sql query?
> >
> >-paul lomack.
> 
> 
> 
> This e-mail, including any attachments, is a confidential 
> business communication, and may contain information that is 
> confidential, proprietary and/or privileged.  This e-mail is 
> intended only for the individual(s) to whom it is addressed, 
> and may not be saved, copied, printed, disclosed or used by 
> anyone else.  If you are not the(an) intended recipient, 
> please immediately delete this e-mail from your computer 
> system and notify the sender.  Thank you.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org