Re: Problems with BIT datatype and preparedStatment
От | Ermengol Bota |
---|---|
Тема | Re: Problems with BIT datatype and preparedStatment |
Дата | |
Msg-id | CABX=gB5T4nQ+muNnffWK1oxe4CDFq6Mkc33dVpu8K0TnSXmvnA@mail.gmail.com обсуждение исходный текст |
Ответ на | Problems with BIT datatype and preparedStatment (Ermengol Bota <ebota@uoc.edu>) |
Список | pgsql-jdbc |
2012/11/26 Thomas Kellerer <spam_eater@gmx.net>
And I agree that boolean is much more better :-)
* Ermengol *
*************************************************
* Els ordinadors no resolen problemes, *
* simplement executen solucions *
*************************************************
Ermengol Bota, 26.11.2012 14:00:Hello,did you try
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();
pstmt.setString(1, "1");
(I find the boolean type much more "descriptive" anyway for true/false columns)
Yes we did it, and the result is the same
Error Code: 42804
Message:
ERROR: column "b" is of type bit but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 31
Actually we solved it using boolean, but I think that may be this could be a bug... I haven't found anyway to set bit (setInt, setString, setObject....), so first of all I ask here if someone knows who's wrong, me or jdbc :-)
Thanks for the answer!
-- * Ermengol *
*************************************************
* Els ordinadors no resolen problemes, *
* simplement executen solucions *
*************************************************
В списке pgsql-jdbc по дате отправления: