X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 0B2C79FA22C for ; Tue, 16 May 2006 15:57:12 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 75439-04 for ; Tue, 16 May 2006 15:57:07 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.184]) by postgresql.org (Postfix) with ESMTP id 7892A9FA15C for ; Tue, 16 May 2006 15:57:07 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id q29so5564nfc for ; Tue, 16 May 2006 11:57:06 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=fUs7gt/kNXFcmZP1BpSC6Lxm+7pI9SerTjqla8/6XRvPLt+EKa6a1fnsieGfi72OKKHwAyhGG+tS8FZm8BF1qvj/qzSiiVRwuRKinCM5pXXrC9013Gwz9qqo7fH9DT2I1ElXJnz+gbXcE58eEbyuq4nNhixmXiax0utdERbVASE= Received: by 10.49.56.20 with SMTP id i20mr63833nfk; Tue, 16 May 2006 11:57:04 -0700 (PDT) Received: by 10.48.248.1 with HTTP; Tue, 16 May 2006 11:57:04 -0700 (PDT) Message-ID: <883e44790605161157jae9dc99pa25a838c9b87b1ae@mail.gmail.com> Date: Tue, 16 May 2006 11:57:04 -0700 From: "Chuck Davis" To: pgsql-jdbc@postgresql.org Subject: Re: JDBC driver and java strings In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <883e44790605161141h11ef46f4h4492214361aea050@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/62 X-Sequence-Number: 15190 Hi Kris: PreparesStatement.setString() is exactly what I am doing and any string with an apostrophe throws a syntax exception. I'm very glad to hear this is supposed to work. Pseudo code for what I am doing on client String s =3D JTextfield.getText(); DataObject.setString(s); send to server _________________________________ on server PreparedStatement.setString(1, DataObject.getString()); PreparedStatement.execute(); I'm using postgres 8.1.3 with development driver for 8.2 since I was having problem with driver version 405. Upgrade to JDBC driver did not help. Thanks for your response. Chuck On 5/16/06, Kris Jurka wrote: > > > On Tue, 16 May 2006, Chuck Davis wrote: > > > Does anybody know if there is a plan to make the driver handle java > > strings appropriately? I have hit a showstopper. If I enter data in > > a JTextfield with an apostrophe the driver chokes with a syntax error. > > I don't know how IBM does it but their JDBC driver handles > > apostrophes without a problem. DB2 has been my main database but I'm > > evaluating Postgresql on Linux. I can't ask my users to avoid > > entering data with an apostrophe and I'm too lazy to program around it > > since I know it can be done otherwise once and for all. > > If you use PreparedStatement.setString, any required quoting/escaping > should be done for you. If you are building a SQL string yourself than > you are responsible for escaping it correctly. You haven't said what > you're doing, but I find it hard to believe that it's postgresql's fault > or that DB2 has some magic to interpret bad data. Perhaps you could be > more specific in what your code is doing? > > Kris Jurka >