Re: bit datatype and getObject()

From: Kris Jurka <books(at)ejurka(dot)com>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: Thomas Kellerer <spam_eater(at)gmx(dot)net>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: bit datatype and getObject()
Date: 2010-12-22 20:13:37
Message-ID: alpine.BSO.2.00.1012221442490.19025@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Wed, 22 Dec 2010, Kevin Grittner wrote:

> What would the Java String look like for SQL B'101' ?

"101"

> Would bool[] make any sense for an object type?

Conceivably.

> I'm not sure byte[] would be out of the question, but it would need
> zero padding on one side or the other, and you would lose the exact
> length. :-(

boolean[] seems better to me than byte[]. One of the appeals of a
distinct/unique type like BitSet is that you can then implement
PreparedStatement.setObject and have it implement the reverse transform to
pass the data to the server with type safety that you wouldn't get using a
String. At the moment we don't do anything intelligent with native array
types, but if we did we wouldn't know if boolean[] should turn into varbit
or bit(1)[].

> What do other drivers do? Is there any guidance in the JDBC
> standard?

The standard says nothing useful. Section 8.3.3 of this document implies
that as an application developer you should just pretend multi-bit strings
don't exist...

http://download.oracle.com/javase/1.5.0/docs/guide/jdbc/getstart/mapping.html

Mysql's documentation shows it using byte[].

http://dev.mysql.com/doc/refman/5.5/en/connector-j-reference-type-conversions.html

Oracle doesn't look like it supports it.

I think IBM uses byte[], I'm not familiar with DB2 data types to
understand what's the equivalent of bytea and what's varbi, but they both
seem to be mapped to byte[].

http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.java.doc/doc/rjvjdata.htm

Kris Jurka

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kevin Grittner 2010-12-22 20:32:26 Re: bit datatype and getObject()
Previous Message Kevin Grittner 2010-12-22 19:35:31 Re: bit datatype and getObject()