}
}
insert.execute();
intsertRowID = new Long(insert.lastInsertedRowId().longValue());
conn.commitTransaction();
} catch (Exception ex) {
ex.printStackTrace();
conn.rollbackTransaction();
} finally {
if (insert != null) {
insert.close();
}
if (conn != null) {
conn.close();
}
}
return intsertRowID;
}
/**
* 添加资源信息点到sde中
* @param pointBean 坐标点 POJO
* @param tbName 图层名称
* @param String typeName 所画的类型 1 点 2 线 3 面
* @return Long sde的id
* @throws Exception
*/
public Long addPointObject(PointBean pointBean, List columnList, String tableName, String typeName) throws Exception {
SeLayer insertLayer = null;
SeConnection conn = null;
Long intsertRowID = null;
SeInsert insert = null;
try {
conn = this.getConnection();
insertLayer = new SeLayer( conn, tableName, "SHAPE");
if (insertLayer == null) {
throw new Exception("找不到空间表:" + tableName);
}
conn.startTransaction();
int arrayLength = columnList.size() + 1 ;
String[] cols = new String[arrayLength];
cols[0] = "SHAPE";
for (int i = 0 ;i
cols[i+1] = columnBean.getName();
}
insert = new SeInsert(conn);
insert.intoTable(insertLayer.getName(), cols);
insert.setWriteMode(true);
SeCoordinateReference coordref = (SeCoordinateReference) insertLayer.getCoordRef();
SeShape shape = new SeShape(coordref);
this.addPoint(pointBean, shape);
} else if ("2".equals(typeName)) {
this.addLine(pointBean, shape);
} else if ("3".equals(typeName)) {
this.addPolygon(pointBean, shape);
}
SeRow row = insert.getRowToSet();
row.setShape(0, shape);
for (int i = 0 ;i
if (columnBean.getTypeObject() == 1) {
row.setNString(i+1, String.valueOf(columnBean.getValObject()));
} else if (columnBean.getTypeObject() == 2) {
row.setInteger(i+1, Integer.parseInt(columnBean.getValObject().toString()));
}else if (columnBean.getTypeObject() == 3) {
row.setDouble(i+1, Double.parseDouble(columnBean.getValObject().toString()));
}
}
insert.execute();
intsertRowID = new Long(insert.lastInsertedRowId().longValue());
conn.commitTransaction();
} catch (Exception ex) {
ex.printStackTrace();
conn.rollbackTransaction();
} finally {
if (insert != null) {
insert.close();
}
if (conn != null) {
conn.close();
}
}
return intsertRowID;
}
sde查询接口实现
[java]
/**
* 查询sde
* @param productId 产品id
* @throws SeException
*/
public SeQuery searchSde (Long productId, String tableName) throws SeException {
SeConnection conn = getConnection();
SeLayer layer = new SeLayer( conn, tableName, "SHAPE");
SeSqlConstruct sqlConstruct = new SeSqlConstruct(layer.getName());
if (productId != null) {
sqlConstruct.setWhere("yid="+productId.intValue());
}
String[] cols = null;
if (tableName.equals("YU_AN