From: | "j(dot)random(dot)programmer" <javadesigner(at)yahoo(dot)com> |
---|---|
To: | oliver(at)opencloud(dot)com, pg(at)fastcrypt(dot)com |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Bug: Driver(8.2dev-500.jdbc3) does not handle boolean->BIT correctly |
Date: | 2005-12-21 04:41:29 |
Message-ID: | 20051221044129.56245.qmail@web32013.mail.mud.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Ok. This while BIT thing is very non-intuitive from my
perspective.
First consider this:
In PSQL:
--------------------------------------
test=# create table foo (bit_val bit(5));
CREATE TABLE
test=# insert into foo (bit_val) values ('B10101');
INSERT 0 1
test=# insert into foo (bit_val) values ('11111');
INSERT 0 1
test=# select * from foo;
bit_val
---------
10101
11111
(2 rows)
------------------------------------
Value 'B11110' IS 100% valid according to
the postgresql manual. (for a BIT(5) column
type).
Now, from JDBC this is impossible.
BOTH of the following give exceptions and
error out.
With val = '11111'
------------------------------------
PreparedStatement pstmt =
con.prepareStatement(
"insert into foo (bit_val) values (?)"
);
pstmt.setString(1, val);
pstmt.executeUpdate();
-----------------------------------
The same with val = 'B11111'
The same with val = true
...etc...
SQLException: SQLState(42804)
Exception in thread "main"
org.postgresql.util.PSQLException: ERROR: column
"bit_val" is of type bit but expression is of type
character varying
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1514)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1299)
-------------------------------------
As far as I can tell, this is a big problem. Or
am I missing something ? [Is there *ANY* way
to get a value into a BIT column from JDBC
via preparedstatements ?]
Best regards,
--j
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Jowett | 2005-12-21 07:22:52 | Re: Bug: Driver(8.2dev-500.jdbc3) does not handle boolean->BIT |
Previous Message | Oliver Jowett | 2005-12-20 21:29:30 | Re: Feature request for setting the role with the URL connection |