Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 54A699FA379 for ; Thu, 14 Dec 2006 08:27:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 96272-08 for ; Thu, 14 Dec 2006 08:27:31 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.logix-tt.com (mail.logix-tt.com [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id 286669FA324 for ; Thu, 14 Dec 2006 08:27:36 -0400 (AST) Received: from kingfisher.intern.logix-tt.com (84-72-188-217.dclient.hispeed.ch [84.72.188.217]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 72CA664BFA for ; Thu, 14 Dec 2006 13:30:31 +0100 (CET) Received: from kingfisher.sec.intern.logix-tt.com (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id B62251818C16C for ; Thu, 14 Dec 2006 13:27:33 +0100 (CET) Date: Thu, 14 Dec 2006 13:27:33 +0100 From: Markus Schaber To: pgsql-jdbc@postgresql.org Subject: Re: String escaping? Message-ID: <20061214132733.709740ba@kingfisher.sec.intern.logix-tt.com> In-Reply-To: <4581318F.4030202@gtech-ua.com> 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> <4581318F.4030202@gtech-ua.com> Organization: www.logix-tt.com X-Mailer: Sylpheed-Claws 2.6.0 (GTK+ 2.8.20; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/75 X-Sequence-Number: 16307 Hi, Vit, Vit Timchishin wrote: > > 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". Yes, the LIKE specific escaping will stay there, but that layer is independent of statement-level escaping. What I wanted to show was: When you create your queries via String concatenation, you have to implement the statement-level escaping yourself, with prepared statements, the driver should completely handle it. That's independent of source-level escaping for String literals in Java, and function-specific escaping inside the text for LIKE or strings in function definitions. Regards, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in Europe! www.ffii.org www.nosoftwarepatents.org