You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Adam Nowalsky <ad...@dandy.net> on 2002/11/27 00:59:07 UTC
looping through ResultSet...later in page
i am developing a web application using tomcat and mysql. the requirements
of the current functionality on which i am working are such that i need to
run a query against a table, and then as i am looping through the ResultSet
from that query, i need to be able to execute additional queries and process
those ResultSets. the basic structure is as follows.
ResultSet rset = (ResultSet) blah;
while (rset.next()) {
NEED TO RUN ANOTHER DATABASE CONNECTION HERE!
}
of course, since i have one connection open, i can't nest another open
connection without throwing a compilation error. i have thought about
trying to store the results of the first query into an array and then
working through that array, but it seems rather rudimentary. i would think
that tomcat (and jsp engines in general) would have some type of container
or some means for assigning the ResultSet to some page context or something
to address this need. for those of you that have also used Cold Fusion,
it's a very simple task there as the query results are assigned to an object
available in that page, and you can loop through that object any time later
basically doing what you want with the results. what are some solutions you
have used to address this need? fyi, a group by in the sql isn't going to
be sufficient...
thanks in advance.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: looping through ResultSet...later in page
Posted by Justin Ruthenbeck <ju...@nextengine.com>.
Assuming you really can't do it in a single query, and assuming you don't
want/can't use a stored procedure, it wouldn't be considered rudimentary to
bring all the data from the first ResultSet locally and walk through it
later ... this is what a disconnected RowSet does. Remember also that
nothing stops a Connection from opening multiple cursors, so consider using
a single connection with multiple Statements nested inside eachother.
Hope that helps...
justin
At 03:59 PM 11/26/2002, you wrote:
>i am developing a web application using tomcat and mysql. the requirements
>of the current functionality on which i am working are such that i need to
>run a query against a table, and then as i am looping through the ResultSet
>from that query, i need to be able to execute additional queries and process
>those ResultSets. the basic structure is as follows.
>
>ResultSet rset = (ResultSet) blah;
>while (rset.next()) {
>NEED TO RUN ANOTHER DATABASE CONNECTION HERE!
>}
>
>of course, since i have one connection open, i can't nest another open
>connection without throwing a compilation error. i have thought about
>trying to store the results of the first query into an array and then
>working through that array, but it seems rather rudimentary. i would think
>that tomcat (and jsp engines in general) would have some type of container
>or some means for assigning the ResultSet to some page context or something
>to address this need. for those of you that have also used Cold Fusion,
>it's a very simple task there as the query results are assigned to an object
>available in that page, and you can loop through that object any time later
>basically doing what you want with the results. what are some solutions you
>have used to address this need? fyi, a group by in the sql isn't going to
>be sufficient...
>
>thanks in advance.
>
>
>--
>To unsubscribe, e-mail: <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>