以 gis 表为例:
drop table gis;
create table gis(id number not null, pos st_geometry not null);
使用如下的 java 代码片断,可以向 gis 表中插入 POINT 类型的 gis 数据:
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement("insert into gis values(?,ST_GEOMFROMTEXT(?))");
for(int i = 0; i < 10; i++) {
ps.setInt(1, 1);
ps.setString(2, "POINT(-137.690708 33.187434)");
ps.addBatch();
}
ps.executeBatch();
conn.commit();
最终效果:
SQL> select id, st_astext(pos) from gis;
ID ST_ASTEXT(POS)
----------- ----------------------------------------------------------------
1 POINT (-137.690708000000001 33.187434000000003)
1 POINT (-137.690708000000001 33.187434000000003)
1 POINT (-137.690708000000001 33.187434000000003)
1 POINT (-137.690708000000001 33.187434000000003)
1 POINT (-137.690708000000001 33.187434000000003)
1 POINT (-137.690708000000001 33.187434000000003)
1 POINT (-137.690708000000001 33.187434000000003)
1 POINT (-137.690708000000001 33.187434000000003)
1 POINT (-137.690708000000001 33.187434000000003)
1 POINT (-137.690708000000001 33.187434000000003)
10 rows fetched.
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。