Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F2910475B8C for ; Wed, 4 Dec 2002 00:26:12 -0500 (EST) Received: from pd3mo3so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net [24.71.223.10]) by postgresql.org (Postfix) with ESMTP id 8947B475EBC for ; Wed, 4 Dec 2002 00:26:11 -0500 (EST) Received: from pd6mr1so.prod.shaw.ca (pd6mr1so-qfe3.prod.shaw.ca [10.0.141.216]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with ESMTP id <0H6K0095CXLI6G@l-daemon> for pgsql-sql@postgresql.org; Tue, 03 Dec 2002 22:22:30 -0700 (MST) Received: from pn2ml9so.prod.shaw.ca (pn2ml9so-qfe0.prod.shaw.ca [10.0.121.7]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with ESMTP id <0H6K003R1XLIHK@l-daemon> for pgsql-sql@postgresql.org; Tue, 03 Dec 2002 22:22:30 -0700 (MST) Received: from kimiko (h24-78-132-76.vc.shawcable.net [24.78.132.76]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with SMTP id <0H6K006H0XLHD4@l-daemon> for pgsql-sql@postgresql.org; Tue, 03 Dec 2002 22:22:30 -0700 (MST) Date: Tue, 03 Dec 2002 21:22:37 -0800 From: Vernon Wu Subject: Re: How does postgres handle non literal string values In-reply-to: <3DE39BC7.8000603@clearmetrix.com> To: pgsql-sql@postgresql.org Reply-To: vernonw@gatewaytech.com Message-id: <2FXV72GHB762VC01VURWMGPMNMD8.3ded911d@kimiko> MIME-version: 1.0 X-Mailer: Opera 6.05 build 1140 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7BIT X-Priority: 3 (Normal) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/47 X-Sequence-Number: 10635 In general, it isn't a good idea to have SQL statements in JSP files. A good practise is using Mode 2. The Struts is a popular Mode 2 framework. If your application is very small and it won't grow into a big one, you can get around using Mode 1. In the situation, the SQL tags of JSTL will be a recommeded mechanism. 11/26/2002 8:05:27 AM, "Charles H. Woloszynski" wrote: >Actually, we use JDBC Prepared Statements for this type of work. You >put a query with '?' in as placeholders and then add in the values and >the library takes care of the encoding issues. This avoids the double >encoding of (encode X as String, decode string and encode as SQL X on >the line). There was a good article about a framework that did this in >JavaReport about a 18 months ago. > >We have gleaned some ideas from that article to create a framework >around using PreparedStatements as the primary interface to the >database. I'd suggest looking at them. They really make your code much >more robust. > >Charlie > > >>"')..." >> >>You *will* want to escape the username and password otherwise I'll be able to >>come along and insert any values I like into your database. I can't believe >>the JDBC classes don't provide >> >>1. Some way to escape value strings >>2. Some form of placeholders to deal with this >> >> >> > >-- > > >Charles H. Woloszynski > >ClearMetrix, Inc. >115 Research Drive >Bethlehem, PA 18015 > >tel: 610-419-2210 x400 >fax: 240-371-3256 >web: www.clearmetrix.com > > > > > >---------------------------(end of broadcast)--------------------------- >TIP 5: Have you checked our extensive FAQ? > >http://www.postgresql.org/users-lounge/docs/faq.html >