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

From Ermengol Bota
Subject Problems with BIT datatype and preparedStatment
Date
Msg-id CABX=gB6H6RqrOd9p38rtiomyqqByovAMpmk6zU5vcJwAHpOovw@mail.gmail.com
Whole thread Raw
Responses Re: Problems with BIT datatype and preparedStatment
Re: Problems with BIT datatype and preparedStatment
List pgsql-jdbc
Hello,

We are having problems when using BIT datatype. Mainly when using it on prepared statement.

The code below is a copy of the one send at: 
pgsql-patches on 2003

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 we are missing something :-)

BIT datatype works well with statement like it:
sqlStmt = "insert into table  values ('1')";

I know that we can do the same behavior with a boolean datatype instead of BIT, and at the end we did this way, but I'm still curious about how should it be done using bit

Thank you for any help!


--
* Ermengol *
*************************************************
* Els ordinadors no resolen problemes, *
* simplement executen solucions           *
*************************************************

pgsql-jdbc by date:

Previous
From: Craig Ringer
Date:
Subject: Re: The column name was not found in this ResultSet
Next
From: Thomas Kellerer
Date:
Subject: Re: Problems with BIT datatype and preparedStatment