afunms

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

          PSAX Trap 翻譯(2)

           接著,用mibbleacmib中所有事件導入數據庫:
          /**
               * 導入事件
               
          */

              
          public void importEvent(){
                  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 SnmpNotificationType)    
          {
                              MibValueSymbol mvs 
          =
           (MibValueSymbol)mvss.get(i);
                              SnmpNotificationType snt 
          =
           (SnmpNotificationType)mvs.getType();
                              String descr 
          = null
          ;
                              String originDescr 
          = null
          ;
                              
          if(snt.getDescription().indexOf(":"> 0
          )
                                  descr 
          = snt.getDescription().substring(snt.getDescription().indexOf(":"+ 2
          );    
                              
          else

                                  descr 
          = snt.getDescription();
                              
          if(descr.indexOf("Return value"> 0
          )
                                  descr 
          = descr.substring(0,descr.indexOf("Return value"
          ));    
                              
          if(descr.indexOf("Data send with the trap"> 0
          )
                                  descr 
          = descr.substring(0,descr.indexOf("Data send with the trap"
          ));
                              descr 
          = descr.replaceAll("\n"" "
          );
                              descr 
          = descr.replaceAll("'""''"
          );
                              originDescr 
          = snt.getDescription().replaceAll("'""''"
          );
                              stat.addBatch(
          "insert into acmib_event(id,symbol,description,origin_description)values(" + id + ",'" + mvs.getName() + "','" + descr + "','" + originDescr + "')"
          );    
                              id
          ++
          ;      
                              
          if( id % 100 == 0
          )
                                  stat.executeBatch();
                          }

                      }

                      stat.executeBatch();
                  }
          catch(Exception e){
                      e.printStackTrace();
                  }

              }

          結果如下:
           

          posted on 2009-10-22 10:52 afunms 閱讀(103) 評論(0)  編輯  收藏


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


          網站導航:
           

          My Links

          News

          留言簿(18)

          隨筆檔案

          相冊

          搜索

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 二连浩特市| 淄博市| 青海省| 康保县| 黎平县| 扶沟县| 克拉玛依市| 湟源县| 新河县| 溧阳市| 新泰市| 顺昌县| 普陀区| 淮阳县| 叙永县| 永州市| 巴东县| 梧州市| 凤冈县| 舞阳县| 慈溪市| 辽阳县| 靖州| 芦山县| 崇明县| 白玉县| 仙桃市| 彰化市| 泽州县| 丽江市| 德州市| 唐海县| 上杭县| 阳东县| 陵川县| 彰武县| 舒兰市| 团风县| 恩平市| 云龙县| 蒙自县|