You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mohammed Zabin <jo...@gmail.com> on 2007/06/25 12:59:31 UTC

Performance

Hi All
I have developed a web site that opens a recordset at start, and while
looping through records of the main ResultSet i Open a new ResultSet for
each record, to get a specific information, then close it. like this:

while( rs.next() ) {
   Statement stmt = dbConn.createStatement();
   ResultSet newRs = stmt.executeQuery("SOME QUERY");
   ......
   .....
   *Some Code Here*
   .....
   .....

   stmt.close();
   newRs.close();
}

I feel that this way is resource-consuming, is it or not, and if it is, what
is the best way to code this code??

Thanks

Re: Performance

Posted by syg6 <sy...@yahoo.com>.
1. This is a question for the 
http://forum.java.sun.com/forum.jspa?forumID=31 java forum , not Tomcat.
2. Yes, it's an incredibly wasteful way of doing things. Change your sql so
the 'extra info' you need is included in the same query. Chances are if you
can do it with two queries you can do it with one.

Bob




Mohammed Zabin wrote:
> 
> Hi All
> I have developed a web site that opens a recordset at start, and while
> looping through records of the main ResultSet i Open a new ResultSet for
> each record, to get a specific information, then close it. like this:
> 
> while( rs.next() ) {
>    Statement stmt = dbConn.createStatement();
>    ResultSet newRs = stmt.executeQuery("SOME QUERY");
>    ......
>    .....
>    *Some Code Here*
>    .....
>    .....
> 
>    stmt.close();
>    newRs.close();
> }
> 
> I feel that this way is resource-consuming, is it or not, and if it is,
> what
> is the best way to code this code??
> 
> Thanks
> 
> 

-- 
View this message in context: http://www.nabble.com/Performance-tf3975410.html#a11284672
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org