pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: j.random.programmer <javadesigner@yahoo.com>
To: oliver@opencloud.com
To: pg@fastcrypt.com
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Bug: Driver(8.2dev-500.jdbc3) does not handle boolean->BIT correctly
Date: Tue, 20 Dec 2005 20:41:29 -0800 (PST)
Message-ID: <20051221044129.56245.qmail@web32013.mail.mud.yahoo.com> (raw)
In-Reply-To: <43A7ACCC.3020601@opencloud.com>

Ok. This while BIT thing is very non-intuitive from my
perspective.

First consider this:
In PSQL:
--------------------------------------
test=# create table foo (bit_val bit(5));
CREATE TABLE
test=# insert into foo (bit_val) values ('B10101');
INSERT 0 1
test=# insert into foo (bit_val) values ('11111');
INSERT 0 1
test=# select * from foo;
 bit_val 
---------
 10101
 11111
(2 rows)
------------------------------------

Value 'B11110' IS 100% valid according to
the postgresql manual. (for a BIT(5) column
type).

Now, from JDBC this is impossible.

BOTH of the following give exceptions and
error out.

With val = '11111'
------------------------------------
PreparedStatement pstmt =    
    con.prepareStatement(
		"insert into foo (bit_val) values (?)"
						);
pstmt.setString(1, val);
pstmt.executeUpdate();
-----------------------------------

The same with val = 'B11111'
The same with val = true
...etc...

SQLException: SQLState(42804)
Exception in thread "main"
org.postgresql.util.PSQLException: ERROR: column
"bit_val" is of type bit but expression is of type
character varying
        at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1514)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1299)
        
-------------------------------------

As far as I can tell, this is a big problem. Or 
am I missing something ? [Is there *ANY* way
to get a value into a BIT column from JDBC
via preparedstatements ?]

Best regards,
--j

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



view thread (14+ messages)  latest in thread

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