X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B015ED1B7C1 for ; Thu, 24 Jun 2004 12:02:19 -0300 (ADT) 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 13669-01 for ; Thu, 24 Jun 2004 15:02:12 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 267B4D1B289 for ; Thu, 24 Jun 2004 12:02:10 -0300 (ADT) Received: (qmail 1134 invoked from network); 24 Jun 2004 15:02:06 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 24 Jun 2004 15:02:06 -0000 Subject: Re: JDBC prepared statements: actually not server From: Dave Cramer Reply-To: pg@fastcrypt.com To: Henner Zeller Cc: "pgsql-hackers@postgresql.org" , "pgsql-jdbc@postgresql.org" In-Reply-To: References: Content-Type: text/plain; charset=ISO-8859-1 Organization: Cramer Consulting Message-Id: <1088089324.1593.63.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Thu, 24 Jun 2004 11:02:04 -0400 Content-Transfer-Encoding: 8bit X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=3.0 tagged_above=0.0 required=5.0 tests=SUSPICIOUS_RECIPS X-Spam-Level: *** X-Archive-Number: 200406/861 X-Sequence-Number: 55411 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