Problems with BIT datatype and preparedStatment

Поиск
Список
Период
Сортировка
От Ermengol Bota
Тема Problems with BIT datatype and preparedStatment
Дата
Msg-id CABX=gB6H6RqrOd9p38rtiomyqqByovAMpmk6zU5vcJwAHpOovw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Problems with BIT datatype and preparedStatment  (Thomas Kellerer <spam_eater@gmx.net>)
Re: Problems with BIT datatype and preparedStatment  (dmp <danap@ttc-cmc.net>)
Список 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 по дате отправления:

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: The column name was not found in this ResultSet
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Re: Problems with BIT datatype and preparedStatment