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 36A1F9FA15C for ; Tue, 16 May 2006 16:06:43 -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 89687-01-2 for ; Tue, 16 May 2006 16:06:29 -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 7A6599FA3A6 for ; Tue, 16 May 2006 16:06:02 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id q29so7156nfc for ; Tue, 16 May 2006 12:06:00 -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=QL3VRnRGrYbpxdzwMVjGdVzm7tAEoBKlgQGONZPDIGB7oMZdM0+kgRQXdLKrqnZcBu4JH9COFF1dqKQpTZGwxqset5LY7vGx8EdZmfu5xAWFjBaYX/dYY5PfoboiNTDS3kbQXa39ALNUCG2b/TmstLrokxP70woGn5XAEz8K7UE= Received: by 10.49.64.20 with SMTP id r20mr71456nfk; Tue, 16 May 2006 12:06:00 -0700 (PDT) Received: by 10.48.248.1 with HTTP; Tue, 16 May 2006 12:06:00 -0700 (PDT) Message-ID: <883e44790605161206i67fe08c5m163057a06087b11e@mail.gmail.com> Date: Tue, 16 May 2006 12:06:00 -0700 From: "Chuck Davis" To: pgsql-jdbc@postgresql.org Subject: Re: JDBC driver and java strings In-Reply-To: <883e44790605161157jae9dc99pa25a838c9b87b1ae@mail.gmail.com> 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> <883e44790605161157jae9dc99pa25a838c9b87b1ae@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/64 X-Sequence-Number: 15192 Kris: I have to apologize. That is not what I was doing in the class! That is my normal m.o. but I was doing it otherwise in this particular class. I will change to a PreparedStatement and assume that it is going to fix my issue! Thanks very much for the confirmation that this is supposed to work and your prompt to reexamine the code. Chuck On 5/16/06, Chuck Davis wrote: > 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 i= t > > > 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 faul= t > > or that DB2 has some magic to interpret bad data. Perhaps you could be > > more specific in what your code is doing? > > > > Kris Jurka > > >