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 BD6F35280F for ; Tue, 7 Jun 2005 15:16:36 -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 30955-02 for ; Tue, 7 Jun 2005 18:16:35 +0000 (GMT) Received: from mir3-fs.mir3.com (www.mir3.com [216.74.11.46]) by svr1.postgresql.org (Postfix) with ESMTP id E1151528A7 for ; Tue, 7 Jun 2005 15:16:34 -0300 (ADT) Received: from archimedes.mirlogic.com ([172.16.2.68]) by mir3-fs.mir3.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 7 Jun 2005 11:19:04 -0700 Subject: Re: DatabaseMetaData and Transactions From: Mark Lewis To: Carl Olivier Cc: pgsql-jdbc@postgresql.org In-Reply-To: <473185057AB4D7118B6C00508B624DDA1C96BB@ALPHENPDC> References: <473185057AB4D7118B6C00508B624DDA1C96BB@ALPHENPDC> Content-Type: text/plain Organization: MIR3, Inc. Date: Tue, 07 Jun 2005 11:16:33 -0700 Message-Id: <1118168193.24149.7.camel@archimedes.mirlogic.com> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-16) Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 07 Jun 2005 18:19:04.0835 (UTC) FILETIME=[632C8530:01C56B8D] X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200506/21 X-Sequence-Number: 12983 You can work around this problem by disabling the V3 protocol, which is by default used when communicating with newer servers. This is a performance hit because the V3 protocol is faster than V2, but shouldn't be too bad. See docs here: http://jdbc.postgresql.org/documentation/head/connect.html#connection- parameters -- Mark Lewis On Tue, 2005-06-07 at 12:54 +0200, Carl Olivier wrote: ... > In 7.3 (using the 7.3 JDBC driver) we were able to do the following: > > === SNIP === > > if (value == null) > { > stmt.setString( index, null ); > } > > === END === > > Some context here. We have a method that constructs a PreparedStatement > taking the sql (eg): > > UPDATE table SET cola = ?, colb = ?, colc = ? > > Or > > INSERT INTO table (cola, colb, colc) VALUES (?, ?, ?) > > And an Object[] of values (in the correct order) for the sql being used in > the PreparedStatement. > > Now - the reason we do a setString(index, null) and not a setNull(index, > Types.SOME_TYPE) is because this method is generic and does not always KNOW > the datatypes for the columns. > > Now, using PostgreSQL 8 (and the new JDBC driver for 8) we ARE still able to > do that when using a 7..3 db server, but get the following error when using > a version 8 PGSQL server: > > ERROR: column "created_by" is of type integer but expression is of type > character varying > > Where created_by is being passed a NULL value (using the setString(index, > null) method). > > Does anyone have any comments/suggestions/etc? Is there any way to get > around this? Or will we need to update our side to always pass in the > column meta data etc for use? > ...