两种插入geometry的sql语句写法

it2022-05-05  113

INSERT INTO test_table_0718 (test,geom) VALUES (10,st_GeomFromText('POINT (116.123 39.345)')); INSERT INTO test_table_0718 (test,geom) VALUES (10,'0000000001402B7852C8FAB0354049856F57A6B003'));

在navicat中执行,两种sql都成功插入对象,但在java代码中,第一种会报异常:

org.postgresql.util.PSQLException: ERROR: function st_geomfromtext(unknown, integer) does not exist   建议:No function matches the given name and argument types. You might need to add explicit type casts.  

代码中,geometry到十六进制字符串转换:

WKBWriter write = new WKBWriter(); byte[] geoByte = write.write(geomtryObject); String strGeo = WKBWriter.toHex(geoByte);

最新回复(0)