I would definitely use the second option.  If you wanted the first I would
also change it to be:

 PrintWriter out = response.getWriter();
    StringBuffer ret = "";
    for (count = 0; rs.next(); count++)
        ret.append(rs.getString("column_name"));         // result of db
query
    out.print(ret.toString());
    out.close();

Carl

-----Original Message-----
From: Rostislav Svoboda [mailto:[EMAIL PROTECTED] 
Sent: 25 May 2004 03:40 PM
To: Tomcat Users List
Subject: PrintWriter performance


Hi all

I'd like to ask you if there's a significant difference in performance
between:

    PrintWriter out = response.getWriter();
    String ret = "";
    for (count = 0; rs.next(); count++)
        ret += rs.getString("column_name");         // result of db query
    out.print(ret);
    out.close();
    
and:

    PrintWriter out = response.getWriter();
    for (count = 0; rs.next(); count++)
        out.print(rs.getString("column_name");      // result of db query
    out.close();

I know I have the extra string which is (theoretically) a slow-down but I
don't know anything about the way how tomcat handles with large strings (in
my 
case about 1MB), if is there any limited buffering etc. 

I know as well I can test it by myself very easilly but I hope someone's 
gonna give me a bit of explanation along with 20 funny stories etc. :)

EOF & thx

Bost

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to