From: | Martin Petras <Martin(dot)Petras(at)coresystems(dot)ch> |
---|---|
To: | "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Array of UUID is not supported |
Date: | 2013-10-10 18:39:05 |
Message-ID: | CE7CC0E8.582AF%martin.petras@coresystems.ch |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-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
From | Date | Subject | |
---|---|---|---|
Next Message | Martin Petras | 2013-10-11 11:38:42 | Re: Array of UUID is not supported |
Previous Message | Mistina Michal | 2013-10-09 13:18:31 | Fail-over string timeout |