BIT vs boolean - Mailing list pgsql-jdbc

From Darin Ohashi
Subject BIT vs boolean
Date
Msg-id F17255C2B596D3119A5600508B44FA6803BB2617@courier.maplesoft.on.ca
Whole thread Raw
List pgsql-jdbc
According to the jdbc doc's one should set a BIT value in a prepared statement
using the setBoolean function.  So I think the following should work:

        stat = con.createStatement();

        stat.execute( "CREATE TABLE bitTable( b BIT )" );

        pstat = con.prepareStatement( "INSERT INTO bitTable( b ) VALUES( ? )" );

        pstat.setBoolean( 1, true );

        pstat.execute();

However with pgsql-jdbc 7.3.3 build 110, I get the following error:

Exception in thread "main" java.sql.SQLException: ERROR:  Cannot parse 't' as a
binary digit

        at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131)
        at
org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.jav
a:505)
        at
org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:
320)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:
48)
        at SQLBug.main(SQLBug.java:34)

Is setBoolean is just printing true or false into a string and expecting the
database side to parse it?  Maybe it should check the type of the column to
determine if the boolean value should be printed as true/false or 0/1 (or
whatever BIT is expecting to see).

Darin

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: executeQuery and busy waiting
Next
From: Barry Lind
Date:
Subject: Re: ENC: Client_encoding