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 E3BBA53D90 for ; Fri, 22 Apr 2005 03:44:11 -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 25943-07 for ; Fri, 22 Apr 2005 06:44:07 +0000 (GMT) Received: from mail.high5.net (randall.high5.net [82.94.255.10]) by svr1.postgresql.org (Postfix) with ESMTP id 2A8DF53D91 for ; Fri, 22 Apr 2005 03:44:06 -0300 (ADT) Received: from webmail.high5.net (mail.high5.net [82.94.255.20]) by mail.high5.net (Postfix) with ESMTP id 13CBD12E829 for ; Fri, 22 Apr 2005 08:44:07 +0200 (CEST) Received: from 82.94.255.26 (SquirrelMail authenticated user laurens) by webmail.high5.net with HTTP; Fri, 22 Apr 2005 08:44:07 +0200 (CEST) Message-ID: <4150.82.94.255.26.1114152247.squirrel@webmail.high5.net> Date: Fri, 22 Apr 2005 08:44:07 +0200 (CEST) Subject: PreparedStatement.setString From: "Bert Hiri" To: pgsql-jdbc@postgresql.org User-Agent: SquirrelMail/1.4.4 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200504/127 X-Sequence-Number: 12734 Hi, Suppose I have a table like: CREATE TABLE test ( id DECIMAL(10) ); When executing the following statement from the psql command prompt: INSERT INTO test(id) VALUES ('12345'); That will succeed. When executing the following from JDBC: PreparedStatement stmt = con.prepareStatement("INSERT INTO test(id) VALUES (?)"); stmt.setString("12345"); stmt.executeUpdate(); This will fail. With the message: Cause: ERROR: column "id" is of type numeric but expression is of type character varying I think this shouldn't fail. This exact same piece of Java code does work with all other databases that I work with. And psql doesn't seem to mind taking a string value either, so why should the PreparedStatement? Regards, Bert