afunms

          My Software,My Dream—Forge a more perfect NMS product.

          PSAX Trap 翻譯(3)

          最后,用mibble把acmib所有代碼和它相應的描述導入數據庫。
              /**
               * 導入acmib中所有類型代碼與描述的對映
               
          */

              
          public void importCode(){
                  MibBrowser mb 
          = new
           MibBrowser();
                  Mib mib 
          = mb.getMib("e:/ACMIB.mib"
          );
                  List mvss 
          =
           (List)mib.getAllSymbols();
                  Connection conn 
          =
           ConnectionManager.getConnection();
                  
          int id = 1
          ;            
                  
          try
          {
                      Statement stat 
          =
           conn.createStatement();
                      
          for(int i=0,n=mvss.size();i<n;i++)

                          
          if(mvss.get(i) instanceof
           MibValueSymbol
                                  
          && ((MibValueSymbol)mvss.get(i)).getType() instanceof SnmpObjectType)    
          {                
                              MibValueSymbol mvs 
          =
           (MibValueSymbol)mvss.get(i);                
                              SnmpObjectType soType 
          =
           (SnmpObjectType)mvs.getType();                
                              
          if(soType.getSyntax() instanceof IntegerType)
          {
                                  IntegerType intType 
          =
           (IntegerType)soType.getSyntax();
                                  MibValueSymbol[] itss 
          =
           intType.getAllSymbols();
                                  
          if(itss.length > 0
          )
                                      
          for(int j=0;j < itss.length;j++)
          {
                                          stat.addBatch(
          "insert into acmib_code(id,symbol,code,description)values("
           
                                          
          + id + ",'" + mvs.getName() + "'," + itss[j].getValue() + ",'" + itss[j].getName() + "')"
          );
                                          id
          ++
          ;
                                      }

                              }

                          }

                          
          if( id % 100 == 0)
                              stat.executeBatch();
                      }

                      stat.executeBatch();
                  }
          catch(Exception e){
                      e.printStackTrace();
                  }
                           
              }
              
          結果如下:

          這樣,為翻譯psax trap的所有的基礎數據都準備好了。

          posted on 2009-10-23 13:59 afunms 閱讀(135) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          My Links

          News

          留言簿(18)

          隨筆檔案

          相冊

          搜索

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 元朗区| 铁岭市| 双桥区| 邛崃市| 华安县| 泽普县| 台前县| 咸阳市| 长春市| 洪湖市| 施秉县| 斗六市| 淮安市| 宜章县| 留坝县| 岚皋县| 元氏县| 海晏县| 武定县| 嘉祥县| 明光市| 读书| 黄龙县| 康定县| 南通市| 达尔| 枣阳市| 台州市| 嘉峪关市| 元阳县| 桐乡市| 太保市| 镇平县| 白沙| 东阳市| 固始县| 雅安市| 奎屯市| 临猗县| 长春市| 德清县|