ITPub博客

首页 > 数据库 > 国内数据库 > 【YashanDB知识库】如何使用jdbc向YashanDB批量插入gis数据

【YashanDB知识库】如何使用jdbc向YashanDB批量插入gis数据

原创 国内数据库 作者:qiaoyikefu 时间:2025-03-21 23:41:25 0 删除 编辑

以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.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70043300/viewspace-3078413/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2025-01-14

  • 博文量
    206
  • 访问量
    188327