pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <pg@fastcrypt.com>
To: Henner Zeller <henner@freiheit.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: JDBC prepared statements: actually not server
Date: Thu, 24 Jun 2004 11:02:04 -0400
Message-ID: <1088089324.1593.63.camel@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.56.0406201352020.8921@kupfersulfat.toxine.lan>
References: <Pine.LNX.4.56.0406201352020.8921@kupfersulfat.toxine.lan>

Please post this to the jdbc list.

Dave
On Sun, 2004-06-20 at 08:09, Henner Zeller wrote:
> Hi,
> 
> While tracking down a query with a JDBC prepared statement, I
> noticed, that the statement actually wasn't prepared but sent to the
> server as 'normal' Statement. In my case, this led to a very slow query
> since the normal statement does not propagate the correct type -- in my
> case I queried an indexed coloumn of type 'int8', which
> was correctly passed to the PreparedStatement with setLong() -- however it
> was sent with a different type to the server (the
> AbstractJdbc1Statement::m_bindTypes[] are never used in this case).
> 
> The reason for this is, that by default, the PreparedStatement is not
> configured to use a server side prepared statement. I assume, this is
> unintended.
> 
> I fixed this by adding this to my local version (current CVS):
> 
> ------------------
> --- org/postgresql/jdbc3/Jdbc3PreparedStatement.java    29 Mar 2004 19:17:12 -0000      1.6
> +++ org/postgresql/jdbc3/Jdbc3PreparedStatement.java    20 Jun 2004 11:54:00 -0000
> @@ -13,6 +13,7 @@
>         public Jdbc3PreparedStatement(Jdbc3Connection connection, String
> sql) throws SQLException
>         {
>                 super(connection, sql);
> +                setUseServerPrepare(true);
>         }
> 
>         public BaseResultSet createResultSet (Field[] fields,
> java.util.Vector tuples, String status, int updateCount, long insertOID)
> throws SQLException
> --------------
> (same for Jdbc2PreparedStatement and Jdbc1PreparedStatement).
> 
> If this is the right way to do ? And if so .. could someone apply
> this patch ?
> 
> Thanks,
>  -hen
> Bücher kaufen und Freie Software fördern | http://bookzilla.de/
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
> 
> 
> 
> !DSPAM:40d5815f68141026638008!
> 
> 
-- 
Dave Cramer
519 939 0336
ICQ # 14675561




view thread (3+ messages)

Message-ID: <1088089324.1593.63.camel@localhost.localdomain>
Permalink:  ../1088089324.1593.63.camel@localhost.localdomain/
Also on:    postgresql.org/message-id/1088089324.1593.63.camel@localhost.localdomain

 · 

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: pg@fastcrypt.com, henner@freiheit.com, pgsql-hackers@postgresql.org
  Subject: Re: JDBC prepared statements: actually not server
  In-Reply-To: <1088089324.1593.63.camel@localhost.localdomain>
  References: <Pine.LNX.4.56.0406201352020.8921@kupfersulfat.toxine.lan> <1088089324.1593.63.camel@localhost.localdomain>

* 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