Re: Problems with BIT datatype and preparedStatment - Mailing list pgsql-jdbc

From Thomas Kellerer
Subject Re: Problems with BIT datatype and preparedStatment
Date
Msg-id k8vprl$vmg$1@ger.gmane.org
Whole thread Raw
In response to Problems with BIT datatype and preparedStatment  (Ermengol Bota <ebota@uoc.edu>)
List pgsql-jdbc
Ermengol Bota, 26.11.2012 14:00:
> Hello,
>
> sql.execute("Create Table jdbc_demo (b bit)");
> PreparedStatement pstmt = conn.prepareStatement("insert into jdbc_demo values (?)");
> pstmt.setBoolean(1,true);  // There is no way to set a value for the bit field  (or I don't know ... :-)
> pstmt.execute();
>
> Theorically (I think) it should works, but it answers:
>
> ERROR: column "b" is of type bit but expression is of type boolean
>
> We are working with PG 9.2.1 (one-click-installer on Ubuntu) and JDBC4 9.2-1002
>
> After trying a lot of different types for the pstmt.setXXXX(), we think that there is something not working well, or
weare missing something :-) 
>

did you try

pstmt.setString(1, "1");

(I find the boolean type much more "descriptive" anyway for true/false columns)



pgsql-jdbc by date:

Previous
From: Ermengol Bota
Date:
Subject: Problems with BIT datatype and preparedStatment
Next
From: Ermengol Bota
Date:
Subject: Re: Problems with BIT datatype and preparedStatment