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 41DE93A5DD1 for ; Sun, 5 Dec 2004 18:50:30 +0000 (GMT) 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 43341-03 for ; Sun, 5 Dec 2004 18:50:25 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) by svr1.postgresql.org (Postfix) with ESMTP id BB3253A5DE4 for ; Sun, 5 Dec 2004 18:50:23 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 58so54583wri for ; Sun, 05 Dec 2004 10:50:23 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=JvyLRYl4znU9353hs2P0aA6JA/jNnUFGY9N+9d1NxcpPVv/n2gknrxqGQ61m/F8UC8A/jXbOP+q9Zb/S6dsuSEqZVx6+rhwFEQwxuHHofdtm3y4KsR1CGOyY1YmCoN87vUoHMFjJbsX7In1VTBzn5Zd+FN6P8RPc1a4ARskaFlo= Received: by 10.54.28.58 with SMTP id b58mr40599wrb; Sun, 05 Dec 2004 10:50:20 -0800 (PST) Received: by 10.54.53.13 with HTTP; Sun, 5 Dec 2004 10:50:20 -0800 (PST) Message-ID: Date: Sun, 5 Dec 2004 13:50:20 -0500 From: Larry White Reply-To: Larry White To: pgsql-jdbc@postgresql.org Subject: prepared statement call fails Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.54 tagged_above=0 required=5 tests=FROM_ENDS_IN_NUMS, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200412/18 X-Sequence-Number: 11684 I'm hoping someone with more experience can help me find a problem in calling a function from Java. This is the first time I'm trying this so I'm guessing it will be straightforward. The function's signature is: add_country(bigint, char(2), char(3), varchar(60)) RETURNS INTEGER ' It works fine if I call it from the command line, like so... select add_country(124,'US', 'USA', 'United States of America'); In java, I call it using the following: CallableStatement proc = null; proc = connection.prepareCall("{ ? = call add_country( ? ? ? ? ) }"); proc.registerOutParameter(1, java.sql.Types.INTEGER); proc.setInt(2, 124); proc.setString(3, code2); // a two character java String proc.setString(4, code3); // a three character java String proc.setString(5, name); // a Java String proc.execute(); with the result that I get the exception: ERROR: syntax error at or near "'JA'" at character 33 (where JA is whatever I'm passing in my second in parameter - defined as char(2). I've inspected the input Strings just before calling to make sure they're what I expected. Is there a mapping published between JDBC statements and Postgresql types? One possibility seems to be that either the char(x) types don't like Strings or the setInt(x,y) doesn't work with BIGINTs, but I'm just guessing. Any help at all would be greatly appreciated. Thanks.