我是Java新手,我需要从数据库中检索SDO_GEOMETRY并使用jdbc将其转换为字符串。如果有人有示例或想法,请与我分享。
帮助将不胜感激。
最好的祝福,
桑杰
最佳答案
看一下JGeometry类。有一个调用空间类型的示例:
/// 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();