pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Thomas Burdairon <tburdairon@entelience.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: PreparedStatement clearParameters
Date: Mon, 20 Feb 2006 12:58:04 -0500 (EST)
Message-ID: <Pine.BSO.4.63.0602201252290.23155@leary.csoft.net> (raw)
In-Reply-To: <FD2E9949-0E9B-4C0D-92E7-2AB587DC319B@entelience.com>
References: <FD2E9949-0E9B-4C0D-92E7-2AB587DC319B@entelience.com>



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




view thread (4+ messages)  latest in thread

Message-ID: <Pine.BSO.4.63.0602201252290.23155@leary.csoft.net>
Permalink:  ../Pine.BSO.4.63.0602201252290.23155@leary.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.63.0602201252290.23155@leary.csoft.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: books@ejurka.com, tburdairon@entelience.com
  Subject: Re: PreparedStatement clearParameters
  In-Reply-To: <Pine.BSO.4.63.0602201252290.23155@leary.csoft.net>
  References: <FD2E9949-0E9B-4C0D-92E7-2AB587DC319B@entelience.com> <Pine.BSO.4.63.0602201252290.23155@leary.csoft.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox