本文介绍了如何使用JDBC从数据库中检索SDO_GEOMETRY?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java新手。我需要从数据库中检索SDO_GEOMETRY并使用jdbc将其转换为字符串。如果任何人有样品或想法请与我分享。

I am new to Java.I need to retrieve SDO_GEOMETRY from database and convert it into string using jdbc.If any one has sample or idea please share with me.

帮助将不胜感激。

最好的问候,

Sanjay。

Best Regards,
Sanjay.

推荐答案

查看类。有一个示例可以调用空间类型:

Have a look into JGeometry class. There is an example to call the spatial type:

     /// reading a geometry from database
     ResultSet rs = statement.executeQuery("SELECT geometry FROM states where name='Florida'");
     STRUCT st = (oracle.sql.STRUCT) rs.getObject(1);
     //convert STRUCT into geometry
     JGeometry j_geom = JGeometry.load(st);

     // ... manipulate the geometry or create a new JGeometry ...

     /// writing a geometry back to database
     PreparedStatement ps = connection.prepareStatement("UPDATE states set geometry=? where name='Florida'");
     //convert JGeometry instance to DB STRUCT
     STRUCT obj = JGeometry.store(j_geom, connection);
     ps.setObject(1, obj);
     ps.execute();

这篇关于如何使用JDBC从数据库中检索SDO_GEOMETRY?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 15:51