pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Martin Petras <Martin.Petras@coresystems.ch>
To: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Array of UUID is not supported
Date: Thu, 10 Oct 2013 18:39:05 +0000
Message-ID: <CE7CC0E8.582AF%martin.petras@coresystems.ch> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

Hey guys,

First of all, thanks a lot for working on the PG JDBC driver!

By using the driver version 9.2-1003-jdbc4 I'm not able to retrieve a column of type UUID[]. The error description is below.

I'm using PG 9.3, version 'PostgreSQL 9.3.0 on x86_64-apple-darwin12.5.0, compiled by Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn), 64-bit' under Mac OS 10.8.5.

Steps to reproduce:
1) run the following queries:
CREATE TABLE uuids (id UUID NOT NULL, ids UUID []);
insert into uuids values ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', '{a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11,a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a12}');

2) run java code:
Class.forName( "org.postgresql.Driver"); // load the driver
Connection db = DriverManager.getConnection("jdbc:postgresql://localhost:7432/test", "postgres", "postgres");
PreparedStatement ps = db.prepareStatement("select * from uuids");
ResultSet rs = ps.executeQuery();
while(rs.next()) {
UUID id = (UUID) rs.getObject("id");
Array ids = rs.getArray("ids");
System.out.println(id + "\t" + ids + "\t" + ids.getArray()); // fails on ids.getArray()
}
rs.close();
ps.close();
db.close();

Expected: ids are a proper array of java.util.UUID objects
Current:
Exception in thread "main" java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc4.Jdbc4Array.getArrayImpl(long,int,Map) is not yet implemented.
at org.postgresql.Driver.notImplemented(Driver.java:710)
at org.postgresql.jdbc2.AbstractJdbc2Array.buildArray(AbstractJdbc2Array.java:745)
at org.postgresql.jdbc2.AbstractJdbc2Array.getArrayImpl(AbstractJdbc2Array.java:171)
at org.postgresql.jdbc2.AbstractJdbc2Array.getArray(AbstractJdbc2Array.java:128)


After quick look in the code around org/postgresql/jdbc2/AbstractJdbc2Array.java:745, it seems that there are two problems:
1) type of objects in the array is resolved to java.sql.Types#OTHER
2) if it is possible to resolve the type to find out it's UUID, it's just up to call UUID.fromString( for each entry in 'input') as input already contains string representations of UUIDs

I hope you'll find some time to fix it as I'd love to use the feature in my project.

Thanks and cheers,

Martin Petras

view thread (5+ messages)  latest in thread

Message-ID: <CE7CC0E8.582AF%martin.petras@coresystems.ch>
Permalink:  ../CE7CC0E8.582AF%25martin.petras@coresystems.ch/
Also on:    postgresql.org/message-id/CE7CC0E8.582AF%martin.petras@coresystems.ch

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: Martin.Petras@coresystems.ch
  Subject: Re: Array of UUID is not supported
  In-Reply-To: <CE7CC0E8.582AF%martin.petras@coresystems.ch>
  References: <CE7CC0E8.582AF%martin.petras@coresystems.ch>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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