X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id ECBBB9DC827 for ; Mon, 20 Feb 2006 13:58:06 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48331-02 for ; Mon, 20 Feb 2006 13:58:06 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail63.csoft.net (mail63.csoft.net [205.205.214.4]) by postgresql.org (Postfix) with SMTP id 76A7E9DC987 for ; Mon, 20 Feb 2006 13:58:04 -0400 (AST) Received: (qmail 14267 invoked by uid 1112); 20 Feb 2006 17:58:04 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 20 Feb 2006 17:58:04 -0000 Date: Mon, 20 Feb 2006 12:58:04 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Thomas Burdairon cc: pgsql-jdbc@postgresql.org Subject: Re: PreparedStatement clearParameters In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.114] X-Spam-Score: 0.114 X-Spam-Level: X-Archive-Number: 200602/153 X-Sequence-Number: 14750 On Mon, 20 Feb 2006, Thomas Burdairon wrote: > I've seen a strange comportment of implementation of PreparedStatement > and especially the clearParameters method. The normal functionnement of > this is that if I create a PreparedStatement, the query is sent once to > the server, and then only parameters are sent to the server. > clearParameters erase parameters already set in the PreparedStatement > object. > > But, it seems the clearParameters method remove us all the benefit of > prepare statements, because the query is sent again on each > executeQuery/executeUpdate call. But without using clearParameters, the > comportment is correct. Yes, this is a problem. The coding of clearParameters clears the type information associated with the PreparedStatement as well as the bind values. This causes the query to get reprepared as it thinks the types have changed. This code is necessary because the statement must be replanned when something like this happens: ps.setInt(1, 1); ps.execute(); ps.setLong(1, 1); ps.execute(); I suspect that just not clearing the type information will fix this, but I'll need to test that a little. Thanks for the report. Kris Jurka