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的所有的基礎數據都準備好了。




































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