pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: j.random.programmer <javadesigner@yahoo.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Bug: Driver(8.2dev-500.jdbc3) does not handle boolean->BIT
Date: Mon, 19 Dec 2005 23:32:00 +0000
Message-ID: <43A742F0.8040801@opencloud.com> (raw)
In-Reply-To: <20051219201451.84589.qmail@web32012.mail.mud.yahoo.com>
References: <20051219201451.84589.qmail@web32012.mail.mud.yahoo.com>

j.random.programmer wrote:
> Running against postgres 8.1
> 
> I have:
> 
> create table foo (bit_val bit);
> 
> If I now try to insert, via the driver's prepared
> statement, a value of java boolean true into
> the bit_val column, I get:
> 
> ---------------------------------
> ERROR COULD NOT SAVE.....
> org.postgresql.util.PSQLException: ERROR: column
> "bit_val" is of type bit but expression is of type
> boolean
> ---------------------------------

JDBC's "BIT" is actually a boolean type. In JDBC3, BIT and BOOLEAN are 
effectively equivalent.

The backend's "bit" type is actually a bitstring that does not have a 
direct equivalent in JDBC.

> This is totally wrong if my reading of the JDBC
> spec is correct. Java boolean values should
> be converted to bitval(1), possibly as '1' and
> then converted back to boolean when read from
> the database.

Actually, the spec says nothing about bitstring types AFAIK.

If you want to do this type conversion and still use setBoolean(), you 
will need to modify your query to do the type conversion there.

-O



view thread (14+ messages)  latest in thread

Message-ID: <43A742F0.8040801@opencloud.com>
Permalink:  ../43A742F0.8040801@opencloud.com/
Also on:    postgresql.org/message-id/43A742F0.8040801@opencloud.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: oliver@opencloud.com, javadesigner@yahoo.com
  Subject: Re: Bug: Driver(8.2dev-500.jdbc3) does not handle boolean->BIT
  In-Reply-To: <43A742F0.8040801@opencloud.com>
  References: <20051219201451.84589.qmail@web32012.mail.mud.yahoo.com> <43A742F0.8040801@opencloud.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