Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7E7B7475CE5 for ; Tue, 26 Nov 2002 11:05:37 -0500 (EST) Received: from clearmetrix.com (unknown [209.92.142.67]) by postgresql.org (Postfix) with ESMTP id C34A2475BEC for ; Tue, 26 Nov 2002 11:05:36 -0500 (EST) Received: from clearmetrix.com (chw.muvpn.clearmetrix.com [172.16.1.3]) by clearmetrix.com (8.11.6/linuxconf) with ESMTP id gAQG5bQ09606; Tue, 26 Nov 2002 11:05:37 -0500 Message-ID: <3DE39BC7.8000603@clearmetrix.com> Date: Tue, 26 Nov 2002 11:05:27 -0500 From: "Charles H. Woloszynski" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Richard Huxton Cc: javaholic , pgsql-sql@postgresql.org Subject: Re: How does postgres handle non literal string values References: <8adde2e2.0211250457.3f0d1c7c@posting.google.com> <200211261535.02419.dev@archonet.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/400 X-Sequence-Number: 10542 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