X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AF1605E4711 for ; Tue, 31 Aug 2004 23:59:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59561-08 for ; Wed, 1 Sep 2004 02:59:29 +0000 (GMT) Received: from mail.iTeamOne.com (unknown [63.173.163.30]) by svr1.postgresql.org (Postfix) with SMTP id 2EAD65E4719 for ; Tue, 31 Aug 2004 23:59:21 -0300 (ADT) Received: from Valens.iTeamOne.com ([10.10.16.57]) by mail.iTeamOne.com (JAMES SMTP Server 2.2.0) with SMTP ID 154 for ; Tue, 31 Aug 2004 21:59:28 -0500 (CDT) Received: from 10.10.16.26 ([10.10.16.26]) by ITeamOne mail server (JAMES SMTP Server @@VERSION@@) with SMTP ID 679 for ; Tue, 31 Aug 2004 21:59:27 -0500 (CDT) Subject: JDBC Update question (quoted strings) From: Gerry Gattis Reply-To: GGattis@iTeamOne.com To: pgsql-jdbc@postgresql.org Content-Type: multipart/alternative; boundary="=-Mc+sNJoYwWXylSfCcY3T" Organization: A Red Mountain Technologies Company Message-Id: <1094007567.8130.34.camel@Kernighan.iTeamOne.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 (1.4.5-1) Date: Tue, 31 Aug 2004 21:59:27 -0500 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200408/168 X-Sequence-Number: 10890 --=-Mc+sNJoYwWXylSfCcY3T Content-Type: text/plain Content-Transfer-Encoding: 7bit I had to make an unexpected adjustment in a query string in order to insert a record into a table. I was would like to know if anyone has a remedy for this. Here is a short description. String strInsert = "insert into myTable (lastName) values (?)"; PreparedStatement stm = conn.prepareCall(strInsert); stm.setString(1, "Smith"); // OK so far stm.execute(); //fails with an error message attribute Smith not found If I use a Statement and manually construct the query string so it contains the single quotes as follows: String strInsert = "insert into myTable (lastName) values ('Smith')"; Statement stm = conn.getStatement(); stm.execute(strInsert); It works like a charm. It looks like there is a difference in the way the PostGres driver handles Strings. I have been through several of the documents on the web site, but have not seen this addressed in any of the configuration articles. The app I am working on needs to work with different RDBMS products. I'm sure I am not the first person to want to do this. Is there a trick to it with PostGres? Best regards, Gerry --=-Mc+sNJoYwWXylSfCcY3T Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit I had to make an unexpected adjustment in a query string in order to insert a record into a table.  I was would like to know if anyone has a remedy for this.  Here is a short description.

String strInsert = "insert into myTable (lastName) values (?)";
PreparedStatement stm = conn.prepareCall(strInsert);
stm.setString(1, "Smith");

// OK so far
stm.execute();
//fails with an error message attribute Smith not found

If I use a Statement and manually construct the query string so it contains the single quotes as follows:
String strInsert = "insert into myTable (lastName) values ('Smith')";
Statement stm = conn.getStatement();
stm.execute(strInsert);


It works like a charm. 

It looks like there is a difference in the way the PostGres driver handles Strings. I have been through several of the documents on the web site, but have not seen this addressed in any of the configuration articles.
The app I am working on needs to work with different RDBMS products. I'm sure I am not the first person to want to do this. Is there a trick to it with PostGres?

Best regards,
Gerry


--=-Mc+sNJoYwWXylSfCcY3T--