BIT vs boolean

From: Darin Ohashi <DOhashi(at)maplesoft(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: BIT vs boolean
Date: 2003-06-27 19:27:34
Message-ID: F17255C2B596D3119A5600508B44FA6803BB2617@courier.maplesoft.on.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Barry Lind 2003-06-27 20:10:18 Re: ENC: Client_encoding
Previous Message Dave Cramer 2003-06-27 19:21:18 Re: executeQuery and busy waiting