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();
did you try
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
And I agree that boolean is much more better :-)
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 * *************************************************