Re: BIT vs boolean - Mailing list pgsql-jdbc

From Fernando Nasser
Subject Re: BIT vs boolean
Date
Msg-id 3EFCAA23.6090103@redhat.com
Whole thread Raw
In response to BIT vs boolean  (Darin Ohashi <DOhashi@maplesoft.com>)
Responses Re: BIT vs boolean
List pgsql-jdbc
I think there is a patch posted for this already.
Kim can confirm if that is so.

Fernando

Darin Ohashi wrote:
> 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match
>


--
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


pgsql-jdbc by date:

Previous
From: Fernando Nasser
Date:
Subject: Re: Multiple Out params in stored procs
Next
From: "scott.marlowe"
Date:
Subject: Re: executeQuery and busy waiting