[postgis-users] JDBC and array of points
Sumit Raja
sumit.raja at raja-consulting.co.uk
Wed Mar 20 04:00:15 PDT 2013
Investigated this a bit further but can't find a solution.
repository=> SELECT '{"POINT(-71.064544 42.28787)", "POINT (51.495727
-34.247342)"}'::geometry[]
;
ERROR: malformed array literal: "{"POINT(-71.064544 42.28787)",
"POINT (51.495727 -34.247342)"}"
LINE 1: SELECT '{"POINT(-71.064544 42.28787)", "POINT (51.495727 -34...
repository=> SELECT ARRAY['POINT(-71.064544 42.28787)', 'POINT
(51.495727 -34.247342)']::geography[];
array
---------------------------------------------------------------------------------------------------------
{0101000020E6100000CB49287D21C451C0F0BF95ECD8244540:0101000020E6100000425F7AFB73BF4940B07614E7A81F41C0}
(1 row)
Is there a way, without having to start patching the JDBC driver to
use the ARRAY syntax?
Thanks
Sumit
On 21/02/2013, Sumit Raja <sumit.raja at raja-consulting.co.uk> wrote:
> Hi,
>
> Postgresql 9.2 and Postgis 2.0 handling of arrays seems different. I have
> code that generates a PreparedStatement that accepts an array of points in
> an ANY clause. I convert the point objects in java to a string
> "POINT(lon,lat)" and use this in the createArrayOf JDBC method.
>
> Unfortunately this doesn't work any more (used to work on 9.1 + 1.5). The
> statement generated is
>
> {"POINT (51.495727 -0.247342)","POINT (1.495727 52.247342)","POINT
> (51.495727 -34.247342)"}
>
> which results in "ERROR: malformed array literal".
>
> How can I fix this issue? In psql simply using the ARRAY[] operator with
> relevant casting seems to work (SELECT ARRAY['POINT(-71.064544
> 42.28787)'::geography]) but as JDBC uses the {} operator I can't see how to
> make this work.
>
> Any one have any ideas?
>
> Sumit
>
--
Raja Consulting Ltd.
Incorporated in England and Wales No. 06454814, Registered Office: 4
Calder Court, Shorebury Point, Amy Johnson Way, Blackpool FY4 2RH
More information about the postgis-users
mailing list