2016-10-22 76 views
0

我想將結果集的值存儲在變量中。請有人幫助我。 這是我的代碼。從mondrian.olap獲取數據。結果

mondrian.rolap.RolapConnection connection=(RolapConnection) 
    RGHelper.getMDXConnection(); 
    Query query = connection.parseQuery(topNUtilisedRG); 

    @SuppressWarnings("deprecation") 
    Result result = connection.execute(query); 

我嘗試使用

final Cell cell = result.getCell(new int[]{0,0}); 

我用日食調試我發現,我需要所有的記錄出現在「細胞」變量來獲取結果。但我不知道如何獲取數據。

在此圖像中我提到,我想節省一些變量值: In this Image I mentioned Values which I want save in some variable

I have gone through this site, but I didn't get the right solution strong text

回答

0

你應該低谷遍歷所有單元格。如果你想擺脫當前單元格的值,你可以調用的getValue()

result.getCell(new int[]{0,0}).getValue() 

但要獲得所有的值必須重複這樣的:

  Axis[] axes = result.getAxes();   
      int[] pos = new int[2]; 
      pos[1] = 0; 
      for (Position position : axes[1].getPositions()) 
      { 
      for (int i=0; i< axes[0].getPositions().size(); i++) 
      { 
       pos[0] = i; 
       result.getCell(pos).getValue(); 
      } 
      pos[1] += 1; 
      }