Take the 2-minute tour ×

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:

Could anyone tell me how to solve this issue?

yours sincerely.

share|improve this question
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> –  mustafa al attar Jul 13 '12 at 10:02

2 Answers 2

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.

share|improve this answer

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,
            length::double precision AS cost
            FROM roads',
         22, 33, false, false), roads
    WHERE edge_id = gid;
share|improve this answer

Your Answer


