[postgis-users] Handling geography types using JDBC

Sundaram, Rama Rama.Sundaram at guycarp.com
Fri Aug 10 14:18:16 PDT 2018


Hi there,
   I have two tables each containing point geometries of type 'geometry'. I need to find out the list of points from the two table within 'x' miles vicinity.  So, I am trying to do something like

select pointA, point B
FROM tableA a
INNER JOIN tableB b on ST_DWithin(a.shape::geography, b.shape::geography, 1609)

While this works without issues in pgAdmin, I get the following error when executing it via JDBC.

org.postgresql.util.PSQLException: ERROR: type "geography" does not exist

I have postgis-jdbc-2.2.1.jar and postgresql-42.2.4.jar in my classpath and using "org.postgis.DriverWrapper" driver class. And my connection string is in the format jdbc:postgresql_postGIS://<host>:<port>/<db>?currentSchema=<schema>

Of course, I can have another column of type 'geography' created in tableA and tableB and execute the query without having to do the runtime type conversion. But I am trying to find out if I can avoid it by registering 'geography' as a valid type with Postgres / PostGIS driver.

Thanks in advance for your insights.

Thanks,
Rama Sundaram

________________________________

This message is intended only for the use of the addressee and may contain
information that is PRIVILEGED AND CONFIDENTIAL.

If you are not the intended recipient, you are hereby notified that any
dissemination of this communication is strictly prohibited. If you have
received this communication in error, please erase all copies of the message
and its attachments and notify the sender immediately. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20180810/09ff537c/attachment.html>


More information about the postgis-users mailing list