0

I am running this simple query

select id,gid from dijkstra_sp('roads',22,33)

This works perfectly fine and returns results in postgres query terminal. However running exactly the same query in java triggers the error:

org.postgresql.util.PSQLException:
ERROR: type "geoms" does not exist
Where: compilation of PL/pgSQL function "dijkstra_sp" near line 6

Could anyone tell me how to solve this issue?

yours sincerely.

1
  • For some reason the error was not posted. The error is: <org.postgresql.util.PSQLException: ERROR: type "geoms" does not exist Where: compilation of PL/pgSQL function "dijkstra_sp" near line 6> Jul 13, 2012 at 10:02

2 Answers 2

1

I figure out what I was doing wrong. I needed to add the datatypes to the connection so that postgres jdbc driver understands the new datatypes. Simply I added

((org.postgresql.PGConnection)SQLConnectionOBJ ).addDataType("box3d",PGbox3d.class); ((org.postgresql.PGConnection)SQLConnectionOBJ ).addDataType("geoms",PGgeometry.class);

and it worked like charm. Thank you sanak for your answer.

0

I am not familiar with JDBC PostgreSQL driver, but it seems that JDBC driver compile PL/pgSQL function at runtime, and another type("geoms") compiling is fail.

If you want to get the same result, try the following plain query instead of above query.

SELECT ROW_NUMBER() OVER()::integer AS id, gid 
    FROM shortest_path(
        'SELECT gid AS id,
            source::integer,
            target::integer,
            length::double precision AS cost
            FROM roads',
         22, 33, false, false), roads
    WHERE edge_id = gid;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.