insert geospatial datatype( mutipolygon) in mysql with java( jdbc)

前端 未结 3 1758
旧时难觅i
旧时难觅i 2020-12-22 10:23

I am using geotools library to extract the location information. With that I am getting an object of type

class com.vividsolutions.jts.geom.MultiPolygon
         


        
3条回答
  •  既然无缘
    2020-12-22 11:09

    It can be binary as well, e.g.

    PreparedStatement preparedStatement = connection.prepareStatement
    ("INSERT INTO table (point, polygon) VALUES (PointFromWKB(?), GeomFromWKB(?))");
    
    WKBWriter writer = new WKBWriter();
    
    preparedStatement.setBytes(1, writer.write(point));
    preparedStatement.setBytes(2, writer.write(polygon));
    
    preparedStatement.executeUpdate();
    

提交回复
热议问题