Re: Problems with BIT datatype and preparedStatment

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Problems with BIT datatype and preparedStatment
Дата
Msg-id k8vprl$vmg$1@ger.gmane.org
обсуждение исходный текст
Ответ на Problems with BIT datatype and preparedStatment  (Ermengol Bota <ebota@uoc.edu>)
Список 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 по дате отправления:

Предыдущее
От: Ermengol Bota
Дата:
Сообщение: Problems with BIT datatype and preparedStatment
Следующее
От: Ermengol Bota
Дата:
Сообщение: Re: Problems with BIT datatype and preparedStatment