Skip site navigation (1) Skip section navigation (2)

Re: [JDBC] JDBC: 2 bugs: Getting a smallint array actually gets an integer array and return type of a boolean array is bit.

From: Kris Jurka <books(at)ejurka(dot)com>
To: Saneesh Apte <san(at)calccit(dot)org>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: [JDBC] JDBC: 2 bugs: Getting a smallint array actually gets an integer array and return type of a boolean array is bit.
Date: 2010-06-29 16:59:22
Message-ID: alpine.BSO.2.00.1006291251060.6109@leary.csoft.net (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-jdbc

On Mon, 28 Jun 2010, Saneesh Apte wrote:

> 	One is minor: the base type of a boolean[] is java.sql.Types.BIT 
> instead or java.sql.Types.BOOLEAN.  At the very least shouldn't these be 
> aliases for the same type?

These are aliases for the same type.  I believe we accept either BOOLEAN 
or BIT as equivalent in all cases.  We default to BIT for historical 
reasons because it was defined first in the JDBC2 spec while BOOLEAN came 
around in the JDBC3 version.

> And secondly the returned type from a smallint[] is an Integer[]
> instead of a Short[].
>

The JDBC spec says that the result of getObject on a Types.SMALLINT value 
should return Integer, so we have followed that for array types as well. 
The spec contains this historical note:

 	The JDBC 1.0 specification defined the Java object mapping for the
 	SMALLINT and TINYINT JDBC types to be Integer. The Java language
 	did not include the Byte and Short data types when the JDBC 1.0
 	specification was finalized. The mapping of SMALLINT and TINYINT
  	to Integer is maintained to preserve backwards compatibility

For more information see table B-3 in the JDBC4.0 spec.

Kris Jurka

In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2010-06-29 17:38:48
Subject: Re: Function works in 8.4 but not in 9.0 beta2 "ERROR: structure of query does not match function result type"
Previous:From: Robert HaasDate: 2010-06-29 16:11:40
Subject: Re: BUG #5520: PG unable to find java stored procs without input parameters

pgsql-jdbc by date

Next:From: Kevin GrittnerDate: 2010-06-29 17:02:39
Subject: Re: Source code for postgress 7.4?
Previous:From: Kevin GrittnerDate: 2010-06-29 16:56:57
Subject: Re: Source code for postgress 7.4?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group