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 6A7EC3A5E01 for ; Sun, 5 Dec 2004 20:05:08 +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 61864-01 for ; Sun, 5 Dec 2004 20:04:57 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.197]) by svr1.postgresql.org (Postfix) with ESMTP id 49ECD3A5C39 for ; Sun, 5 Dec 2004 20:04:57 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 69so36678wri for ; Sun, 05 Dec 2004 12:04:57 -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:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=Mzdt7nEdJZmU3SkchLOVXSji1GWow72oddyq/JvPF00VFHsliTfNQBgY2wyjdDU2HBIt3Ip4AlABAaz04Tt+zqfHl9+R7C4pNQwVfMycgNqz3vpudNnlA2jSxmY1qupxsjunRtS2PBTCHCHRkr4eeTusY73bRWuO1ep3i/oGmYk= Received: by 10.54.8.47 with SMTP id 47mr1094190wrh; Sun, 05 Dec 2004 12:04:57 -0800 (PST) Received: by 10.54.53.13 with HTTP; Sun, 5 Dec 2004 12:04:57 -0800 (PST) Message-ID: Date: Sun, 5 Dec 2004 15:04:57 -0500 From: Larry White Reply-To: Larry White To: Thomas Hallgren Subject: Re: prepared statement call fails Cc: pgsql-jdbc@postgresql.org In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <41B35CC6.2030800@mailblocks.com> <41B3663B.1010003@mailblocks.com> 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/24 X-Sequence-Number: 11690 Well, you seem to be right after all. :-) I tried your approach and it works fine. I'm using functions in part for security reasons and I'm not sure if there are any implications. I guess I can still lock down the tables and grant only execute rights on the functions. The fact that they get called in a query probably doesn't matter. In any case this seems like a bug in the driver, or in the documentation at a minimum. Thanks very much for your help. On Sun, 05 Dec 2004 20:49:15 +0100, Thomas Hallgren wrote: > Larry White wrote: > > > > >Thanks Thomas. I'll try it your way to see what happens, but > >according to the Postgresql documentation, it should support callable > >statements. I posted the relevent text from the JDBC section of the > >online docs below: > > > > > > PostgreSQL's JDBC driver fully supports calling PostgreSQL > >stored functions. > > > > Example 31-4. Calling a built in stored function > > > > This example shows how to call a PostgreSQL built in > >function, upper, which simply converts the supplied > >string argument to uppercase. > > > > // Turn transactions off. > > con.setAutoCommit(false); > > // Procedure call. > > CallableStatement upperProc = con.prepareCall("{ ? = call > >upper( ? ) }"); > > upperProc.registerOutParameter(1, Types.VARCHAR); > > upperProc.setString(2, "lowercase to uppercase"); > > upperProc.execute(); > > String upperCased = upperProc.getString(1); > > upperProc.close(); > > > > > > > Ok, I did write AFAIK. Apparently my knowlegde didn't extend far enough :-) > > The JDBC driver must do some trick then, and make an attempt to convert > what you wrote into what I suggested. With some risk of getting flogged, > I must admin that I disagree with that implementation since the > interface doc's for JDBC mandates that the CallableStatement is for > Stored Procedures only. Patching it so that it can call functions will > cause future problems once the backend really do implement stored > procedures correctly. > > My advice would be to stick with prepared statements until that happens. > I know for certain that it works. > > Regards, > Thomas Hallgren > >