Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

2 Answers

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;
share|improve this answer
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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