Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 33F339FA162 for ; Thu, 14 Dec 2006 07:12:30 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 88870-03 for ; Thu, 14 Dec 2006 07:12:20 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.gtech.kiev.ua (mail.gtech.kiev.ua [213.186.209.2]) by postgresql.org (Postfix) with ESMTP id 9F7FF9F9F08 for ; Thu, 14 Dec 2006 07:12:23 -0400 (AST) Received: from localhost ([127.0.0.1]) by mail.gtech.kiev.ua (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits)) for pgsql-jdbc@postgresql.org; Thu, 14 Dec 2006 14:12:23 +0200 Message-ID: <4581318F.4030202@gtech-ua.com> Date: Thu, 14 Dec 2006 13:12:15 +0200 From: Vit Timchishin User-Agent: Thunderbird 1.5.0.8 (X11/20060911) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: String escaping? References: <50899926-5B68-42EC-B126-75EBC7E38BF4@mac.com> <4580368D.8070300@enterprisedb.com> <1166032066.27428.92.camel@archimedes> <20061214115414.2cff1417@kingfisher.sec.intern.logix-tt.com> In-Reply-To: <20061214115414.2cff1417@kingfisher.sec.intern.logix-tt.com> Content-Type: text/plain; charset=KOI8-U Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.862 tagged_above=0 required=5 tests=BAYES_50, FROM_LOCAL_NOVOWEL X-Spam-Level: ** X-Archive-Number: 200612/74 X-Sequence-Number: 16306 Markus Schaber wrote: > Hi, Mark, > > Mark Lewis wrote: > > >>> You don't generally need to escape your strings if you're using >>> PreparedStatements. >>> >>> >> The only exception to this rule is backslashes and (when using LIKE) the >> '%' and '_' characters. Although if you're running 8.2 and turn the >> standard_conforming_strings setting ON then you don't need to worry >> about backslashes. >> > > That sounds confusing. > > I always thought that the Strings that I set with setString() don't > have to be escaped at all, the Driver will handle it transparently (by > either escaping for V2 protocol, or using BIND with the appropriate > encoding). > > But, of course, when I have a String Literal in the source, I need to > add a layer of Java escaping for ", \, and some others. > > I suppose you've missed the main: "you need to escape only when you are using LIKE".