【发布时间】:2013-10-24 05:36:54
【问题描述】:
我正在尝试将几何对象存储到我的 postgist 数据库中,该数据库有一个带有几何列的表。我从另一个带有几何列的表中获取了几何值,然后打印了之前得到的值,没关系。为了存储几何值,我使用下一个函数:
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:无法推断要用于的 SQL 类型 org.postgis.Point 的一个实例。将 setObject() 与显式一起使用 类型值以指定要使用的类型。
有人知道怎么保存吗? ='(
提前致谢!
【问题讨论】:
标签: java postgresql postgis