Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Spring JDBC插入postgis多多边形数据类型时出错_Java_Postgresql_Postgis_Spring Jdbc - Fatal编程技术网

Java 使用Spring JDBC插入postgis多多边形数据类型时出错

Java 使用Spring JDBC插入postgis多多边形数据类型时出错,java,postgresql,postgis,spring-jdbc,Java,Postgresql,Postgis,Spring Jdbc,我试图使用Spring JDBC将数据插入postgres postgis数据库,但出现以下错误: org.postgresql.util.PSQLException: ERROR: Geometry has Z dimension but column does not at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161) at org.postgres

我试图使用Spring JDBC将数据插入postgres postgis数据库,但出现以下错误:

org.postgresql.util.PSQLException: ERROR: Geometry has Z dimension but column does not
at     org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:560)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:363)
at com.springjdbc.jdbc.EutranCellGeoComputedInfoDAOImpl.save(EutranCellGeoComputedInfoDAOImpl.java:33)
at com.springjdbc.jdbc.SpringMain.main(SpringMain.java:48)
我正在使用Preparestatement setObject方法来设置posgis数据类型

        ps.setObject(2, cityinfo.getCellShape().toString(),java.sql.Types.OTHER);
        ps.setObject(3, cityinfo.getCellLocation().toString(),java.sql.Types.OTHER);
表:

CREATE TABLE area_details_table
(
  area geography(MultiPolygon,4326),
  location geography(Point,4326),
  calculated_cell_radius numeric(8,2),
  latitude numeric(9,6),
  longitude numeric(9,6),
  id smallint,
)

需要帮助解决此问题,或者是否有其他方法使用Spring JDBC保存postgis数据类型。

查看错误消息:

org.postgresql.util.PSQLException:错误:几何体具有Z维度,但 列不存在

这意味着,您试图在只接受二维数据的列中插入Z坐标的数据

如果所有数据都有Z坐标,只需将表格更改为使用MultiPolygonZ和PointZ,而不是使用MultiPolygon和Point

当然,如果有混合数据,部分有Z坐标,部分没有Z坐标,这将不起作用。在这种情况下,您可以使用完全动态的几何图形/地理列,这意味着不使用几何图形类型:

CREATE TABLE area_details_table
(
  area geography,
  location geography,
  calculated_cell_radius numeric(8,2),
  latitude numeric(9,6),
  longitude numeric(9,6),
  id smallint
);

如果不使用/不需要Z坐标,则使用2D或ST_Force2Dgeom制作新版本的几何图形
CREATE TABLE area_details_table
(
  area geography,
  location geography,
  calculated_cell_radius numeric(8,2),
  latitude numeric(9,6),
  longitude numeric(9,6),
  id smallint
);