pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Lewis <mark.lewis@mir3.com>
To: Carl Olivier <carl@zero-one.co.za>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: DatabaseMetaData and Transactions
Date: Tue, 07 Jun 2005 11:16:33 -0700
Message-ID: <1118168193.24149.7.camel@archimedes.mirlogic.com> (raw)
In-Reply-To: <473185057AB4D7118B6C00508B624DDA1C96BB@ALPHENPDC>
References: <473185057AB4D7118B6C00508B624DDA1C96BB@ALPHENPDC>

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?
> 
...




view thread (9+ messages)  latest in thread

Message-ID: <1118168193.24149.7.camel@archimedes.mirlogic.com>
Permalink:  ../1118168193.24149.7.camel@archimedes.mirlogic.com/
Also on:    postgresql.org/message-id/1118168193.24149.7.camel@archimedes.mirlogic.com

 · 

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: mark.lewis@mir3.com, carl@zero-one.co.za
  Subject: Re: DatabaseMetaData and Transactions
  In-Reply-To: <1118168193.24149.7.camel@archimedes.mirlogic.com>
  References: <473185057AB4D7118B6C00508B624DDA1C96BB@ALPHENPDC> <1118168193.24149.7.camel@archimedes.mirlogic.com>

* 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