Unix Technical Forum

Bug extracting bit value

This is a discussion on Bug extracting bit value within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> Hello! When I extract a bit value by JDBC I get an Boolean Object - even for bit(3)! CREATE ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 12:20 AM
Holger Schulz
 
Posts: n/a
Default Bug extracting bit value

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



---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-16-2008, 12:20 AM
Oliver Jowett
 
Posts: n/a
Default Re: Bug extracting bit value

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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:47 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com