Re: PreparedStatement.setXXX - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: PreparedStatement.setXXX
Date
Msg-id 42DC36AF.6060601@opencloud.com
Whole thread Raw
In response to PreparedStatement.setXXX  ("Roberta Campo" <rcampo@mm.eutelsat.org>)
List pgsql-jdbc
Roberta Campo wrote:

> A. Using the setArray method :
> This requires the implementation of the interface java.sql.Array :
> - which methods are required in this case ?
> - is there any available implementation of this class ? :)

Someone else replied to this with an implementation..

The driver's Array support is pretty bad currently. It will only work if
the Array implementation implements:

 - getBaseTypeName() returns the underlying postgresql type name ("int")
 - toString() returns a correctly-formatted array string ("{1,2,3}")

Proper support for arbitrary Array implementations (and bare arrays via
setObject) has been on my todo list for ages but it's no longer a high
priority for our application so I doubt I'll work on it any time soon :/

> B. Using the setObject(colnumber, String, type ) method :
> This should require less implementation than the Array, shouldn't it ?
> - how to specify the type int[] ?

JDBC has no mechanism to specify a particular array type via a Types.*
constant unfortunately :(

> C. Using different drivers / protocol versions / ...

Using protocol version 2 as Dave Cramer suggests is a short-term fix but
you don't want to be using that in the longer term..

-O

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Timestamp Conversion Woes Redux
Next
From: Oliver Jowett
Date:
Subject: Re: Timestamp Conversion Woes Redux