setBoolean with BIT column - Mailing list pgsql-jdbc

From Kevin Schmidt
Subject setBoolean with BIT column
Date
Msg-id 3D889304.3070303@enterworks.com
Whole thread Raw
List pgsql-jdbc
Hi,

I am using PostgreSQL 7.2 and have a column of type BIT that I am
inserting into with a PreparedStatement.  In reading the Javadoc for
PreparedStatement, the setBoolean() method seems to be the correct way
to set a parameter for a BIT datatype as the description for the method is:

"Sets the designated parameter to the given Java boolean value.  The
driver converts this to an SQL BIT value when it sends it to the database."

When I try this though, I get an error:

"cannot parse t as a binary digit"

In looking at the PreparedStatement's SQL, it seems to be constructing
something like:

insert into myTable values('t')

which would explain the error message.

So, is this a bug in the JDBC driver in that it doesn't do the
conversion to an SQL BIT value when sent to the database like the
Javadoc says?  If not, what is the correct way to set a parameter to a
BIT value in a PreparedStatement?

I know I can probably use a BOOLEAN column and things will work fine,
but I expected this to work using a BIT datatype.

Thanks,

Kevin


pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: JDBC and fetching the OID of an insert
Next
From: "Michael Paesold"
Date:
Subject: Implementing JDBC3 methods (Was: JDBC and fetching the OID of an insert)