0

I use @query to Insert X,Y to Geometry in PostgreSQL.

@Modifying
@Query(value = " insert into mypoints (name,geom) values (:name,SRID=4326;POINT(:x :y))", nativeQuery = true)
@Transactional
void addSPCTY(@Param("name") String ten,@Param("x") String x,@Param("y") String y);

Right now it ends up with an error

Error in Java: org.postgresql.util.PSQLException: ERROR: syntax error near ;

3
  • 1
    Shouldnt SRID=4326;POINT(:x :y) be more like ST_GeomFromText('POINT(-71.060316 48.432044)', 4326)) (I dont know java). See: Inserting point into PostGIS?
    – Bera
    Commented Apr 21, 2020 at 5:30
  • 2
    Does this answer your question? Inserting point into PostGIS?
    – CL.
    Commented Apr 21, 2020 at 9:53
  • Tks . But it error: ERROR: parse error - invalid geometry Hint: "POINT(:x" <-- parse error at position 8 within geometry Commented Apr 21, 2020 at 12:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.