Hi, Probably a negligible performance difference. But the first one is a bad design because it mixes the result set processing with the presentation very closely. The getString, like most ResultSet calls, can throw a SQLException, and you'd have to handle that. That means your out.println calls have to be inside a try/catch clause, which is OK, but there's a good reason PrintWriter is used by servlet API, and a good reason why Sun wrote it to not throw IOExceptions ;) Let it and the container handle the buffering for you.
Yoav Shapira Millennium Research Informatics >-----Original Message----- >From: Rostislav Svoboda [mailto:[EMAIL PROTECTED] >Sent: Tuesday, May 25, 2004 9:40 AM >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] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
