我試圖將幾何對象存儲到我的postgist數據庫中,該數據庫具有帶幾何列的表。我從具有幾何列的另一個表中獲取了幾何值,並且打印了之前獲得的值,這沒關係。要存儲幾何值我用下面的函數:如何使用java在Postgis數據庫中存儲幾何點
static void insertaGeometria(Geometry geom, int idInstalacion) throws ClassNotFoundException, SQLException{
Connection congeom = conectarPGA();
String geomsql ="INSERT INTO georrepositorio.geometria(id, point) VALUES (?,?)";
PreparedStatement psSE= congeom.prepareStatement(geomsql);
psSE.setInt(1, idInstalacion);
psSE.setObject(2, geom);
psSE.execute();
psSE.close();
congeom.close();
}
但我總是得到這樣的錯誤:
org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.postgis.Point. Use setObject() with an explicit Types value to specify the type to use.
難道有人知道如何保存呢? !='。(
在此先感謝
什麼情況下做jpa –
@ bob-cac不確定(我不使用JPA);看看[如果這有幫助](http://stackoverflow.com/q/2387170/327026) –