From: | Ermengol Bota <ebota(at)uoc(dot)edu> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Problems with BIT datatype and preparedStatment |
Date: | 2012-11-26 13:00:28 |
Message-ID: | CABX=gB6H6RqrOd9p38rtiomyqqByovAMpmk6zU5vcJwAHpOovw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
http://archives.postgresql.org/pgsql-patches/2003-06/msg00402.php
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 *
*************************************************
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Kellerer | 2012-11-26 13:12:49 | Re: Problems with BIT datatype and preparedStatment |
Previous Message | Zsolt Kúti | 2012-11-22 09:25:33 | Re: The column name <col> was not found in this ResultSet |