小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

利用Java進行AcrSDE開發(fā)實例

 WindySky 2009-01-08
利用Java進行AcrSDE開發(fā)實例:
ArcSDE提供了C API和Java API兩種接口。這里我們只導論如何通過Java API進行arcSDE開發(fā)。
開發(fā)環(huán)境:
JDK 1.5
WIN 插P
Eclipse 3.1+MyEclipse
ArcSDE for Oracle 9i
(1)把arcSDE java API所需要的三個jar包導到web\lib目錄,包括jsde90_sdk.jar,jpe90_sdk.jar ,concurrent.jar;
(2)添加點:
public class AddPointBean {
    public static boolean process(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        Map map=null;
        if (request.getSession().getAttribute(StaticConstant.SESSION_MAP) == null) {
            String strErr = "地圖還沒有初始化";
            request.setAttribute(StaticConstant.REQUEST_ERROR, strErr); 字串3
            return false;
        }
        map=(Map)request.getSession().getAttribute(StaticConstant.SESSION_MAP);
        //連接SDE
        SeConnection conn = null;
        String server = "menglikunm";
        int instance = 5151;
        String database = "ora";
        String user = "sde";
        String password = "sde";
        SeLayer insertLayer=null;
        try {
            conn = new SeConnection(server, instance, database, user, password);

字串1


            Vector layerList = conn.getLayers();
            for (int index = 0; index < layerList.size(); index++) {
                SeLayer layer = (SeLayer) layerList.elementAt(index);
                // Displays the layer’s name
                System.out.println(layer.getName());
                // Displays the layer’s ID
                System.out.println(layer.getID().longValue());
                // Displays the layer’s spatial column name
字串7

                System.out.println(layer.getSpatialColumn());
                if(layer.getName().equalsIgnoreCase("ZHENGFUJIGUAN")){
                    insertLayer=layer;
                }
            }
        } catch (SeException e) {
            e.printStackTrace();
            return false;
        }
        //開始插入數(shù)據(jù)
        try{ 字串6
            conn.startTransaction();
            String[] cols = new String[2];
            cols[0] = new String("NAME");
            cols[1] = insertLayer.getSpatialColumn();
            SeInsert insert = new SeInsert(conn);
            insert.intoTable(insertLayer.getName(),cols);
            insert.setWriteMode(true);
            SeCoordinateReference coordref =(SeCoordinateReference)insertLayer.getCoordRef();
            SeShape shape = new SeShape(coordref);
            double x=map.toMapPoint(10,10).getX();

字串9


            double y=map.toMapPoint(10,10).getY();
           
            int numPts = 1;
            SDEPoint[] ptArray = new SDEPoint[numPts];
            ptArray[0] = new SDEPoint(x, y);
            shape.generatePoint(numPts, ptArray);
           
            SeRow row = insert.getRowToSet();
            row.setString(0, "測驗點");
            row.setShape(1,shape);
            insert.execute(); 字串7
            insert.close();
            conn.commitTransaction();
            conn.close();
        }catch(Exception ex){
            conn.rollbackTransaction();
            conn.close();
            ex.printStackTrace();
        }
        return true;
    }
}(3)刪除點:
public class DeletePointBean {
    public static boolean process(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //連接SDE

字串5


        SeConnection conn = null;
        String server = "menglikunm";
        int instance = 5151;
        String database = "ora";
        String user = "sde";
        String password = "sde";
        try {
            conn = new SeConnection(server, instance, database, user, password);
            Vector layerList = conn.getLayers();
            for (int index = 0; index < layerList.size(); index++) {
                SeLayer layer = (SeLayer) layerList.elementAt(index); 字串5
                // Displays the layer’s name
                System.out.println(layer.getName());
                // Displays the layer’s ID
                System.out.println(layer.getID().longValue());
                // Displays the layer’s spatial column name
                System.out.println(layer.getSpatialColumn());
            }
        } catch (SeException e) {
            e.printStackTrace();

字串8


            return false;
        }
        //開始刪除數(shù)據(jù)
        try{
            conn.startTransaction();
            SeDelete delete=new SeDelete(conn);
            SeObjectId id=new SeObjectId(641);
            delete.byId("ZHENGFUJIGUAN",id);
            conn.commitTransaction();
            delete.close();
        }catch(Exception ex){
            conn.rollbackTransaction(); 字串4
            conn.close();
            ex.printStackTrace();
        }
        return true;
    }
}
 

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多