pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedBug extracting bit value
3+ messages / 3 participants
[nested] [flat]
* Bug extracting bit value
@ 2006-10-01 10:57 Holger Schulz <hst1@online.de>
0 siblings, 1 reply; 3+ messages in thread
From: Holger Schulz @ 2006-10-01 10:57 UTC (permalink / raw)
To: pgsql-jdbc
Hello!
When I extract a bit value by JDBC I get an Boolean Object - even for bit(3)!
CREATE TABLE testbits
(
cbitone bit(1),
cbitthree bit(3),
cvarbit varbit,
cboolean bool
)
INSERT INTO testbits
("cbitone", "cbitthree", "cvarbit", "cboolean") values
(
B'1',
B'101',
B'0101',
true
)
------------------
In Java:
select * from testbits
Object oValue = m_resultSet.getObject(i);
returns:
| cbitone | cbitthree | cvarbit | cboolean |
-|---------------------|---------------------|--------------------------------|---------------------|-
| true | false | 0101 | true |
| 'java.lang.Boolean' | 'java.lang.Boolean' | 'org.postgresql.util.PGobject' | 'java.lang.Boolean' |
------------------
When I use getString() instead of getObject() I get this result:
Object oValue = m_resultSet.getObject(i);
| cbitone | cbitthree | cvarbit | cboolean |
-|--------------------|--------------------|--------------------|--------------------|-
| '1' | '101' | '0101' | 't' |
| 'java.lang.String' | 'java.lang.String' | 'java.lang.String' | 'java.lang.String' |
------------------
Same statement in pgAdmin III returns:
1;101;"0101";t
------------------
Tested with:
PostgreSQL 8.1.4 on Windows 2000
JDBC driver: postgresql-8.2dev-503.jdbc3.jar AND postgresql-8.1-407.jdbc3.jar
Holger
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Bug extracting bit value
@ 2006-10-01 21:25 Oliver Jowett <oliver@opencloud.com>
parent: Holger Schulz <hst1@online.de>
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Jowett @ 2006-10-01 21:25 UTC (permalink / raw)
To: Holger Schulz <hst1@online.de>; +Cc: pgsql-jdbc
Holger Schulz wrote:
> When I extract a bit value by JDBC I get an Boolean Object - even for bit(3)!
That's a bit strange, if varbit(n) returns a custom PGobject I'd expect
bit(n) to do the same..
Again this is a type where there's no good JDBC mapping for it though ..
maybe boolean[] would be right, but then you can also have real arrays
of bools..
The confusing thing is that JDBC's Types.BIT really means "boolean" not
"bit(n)" :(
-O
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Bug extracting bit value
@ 2006-10-30 20:41 Kris Jurka <books@ejurka.com>
parent: Oliver Jowett <oliver@opencloud.com>
0 siblings, 0 replies; 3+ messages in thread
From: Kris Jurka @ 2006-10-30 20:41 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; +Cc: Holger Schulz <hst1@online.de>; pgsql-jdbc
On Sun, 1 Oct 2006, Oliver Jowett wrote:
> Holger Schulz wrote:
>
>> When I extract a bit value by JDBC I get an Boolean Object - even for
>> bit(3)!
>
> That's a bit strange, if varbit(n) returns a custom PGobject I'd expect
> bit(n) to do the same..
Well, varbit only returns a bare PGobject not a custom implementation, so
it's rather useless. Any type the driver knows nothing about gets this,
so we could remove the bit behavior, but I'm not sure it's a clear winner.
>
> Again this is a type where there's no good JDBC mapping for it though ..
> maybe boolean[] would be right, but then you can also have real arrays of
> bools..
Right, this would be good for getObject, but setObject wouldn't know what
to do with it.
Kris Jurka
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-10-30 20:41 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-10-01 10:57 Bug extracting bit value Holger Schulz <hst1@online.de>
2006-10-01 21:25 ` Oliver Jowett <oliver@opencloud.com>
2006-10-30 20:41 ` Kris Jurka <books@ejurka.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox