Re: Array of UUID is not supported

From: Martin Petras <Martin(dot)Petras(at)coresystems(dot)ch>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Cc: Martin Petras <Martin(dot)Petras(at)coresystems(dot)ch>
Subject: Re: Array of UUID is not supported
Date: 2013-10-11 11:38:42
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hey guys,

There is a pull request containing the fix:

It would be great to have it review and merged to the master branch.


Martin Petras

From: Martin Petras <martin(dot)petras(at)coresystems(dot)ch<mailto:martin(dot)petras(at)coresystems(dot)ch>>
Date: štvrtok, 10. októbra 2013 20:39
To: "pgsql-jdbc(at)postgresql(dot)org<mailto:pgsql-jdbc(at)postgresql(dot)org>" <pgsql-jdbc(at)postgresql(dot)org<mailto:pgsql-jdbc(at)postgresql(dot)org>>
Subject: [JDBC] Array of UUID is not supported

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:
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( {
UUID id = (UUID) rs.getObject("id");
Array ids = rs.getArray("ids");
System.out.println(id + "\t" + ids + "\t" + ids.getArray()); // fails on ids.getArray()

Expected: ids are a proper array of java.util.UUID objects
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(
at org.postgresql.jdbc2.AbstractJdbc2Array.buildArray(
at org.postgresql.jdbc2.AbstractJdbc2Array.getArrayImpl(
at org.postgresql.jdbc2.AbstractJdbc2Array.getArray(

After quick look in the code around org/postgresql/jdbc2/, 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

In response to


Browse pgsql-jdbc by date

  From Date Subject
Next Message saisantoshi 2013-10-12 08:19:03 Java String saving as unicode in database
Previous Message Martin Petras 2013-10-10 18:39:05 Array of UUID is not supported