1

我正在构建一个 Java 服务,它使用 olap 数据源(XML-A 服务器)生成报告(使用 JasperReports 4.0.5 库)。在 iReport 上,我编写了 XMLA-MDX 查询并正确地可视化了预览。但是当我在 Java 中运行它时,我在执行时收到错误“ line 1:1: unexpected token: [Measures] ”!详细消息说:net.sf.jasperreports.engine.JRRuntimeException: Invalid field mapping "[Measures].[Full price]"。这是代码:

 try{
      net.sf.jasperreports.engine.util.JRProperties.setProperty("net.sf.jasperreports.query.executer.factory.xmla-mdx", "net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuterFactory");

      String url = "http://localhost/olap/msmdpump.dll";
      String ds = "localhost";
      String cat = "MyCat";

      Map parameters = new HashMap();
      parameters.put(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_DATASOURCE, ds);
      parameters.put(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_CATALOG, cat);
      parameters.put(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_URL, url);

      String fileJasper = "I:\\Work\\prod_ireport\\myOlapReport.jasper";
      JasperPrint jp = JasperFillManager.fillReport(fileJasper, parameters);
 }
 catch (Exception e) {
      System.out.println(e.getMessage());
 }

这是 jrxml 文件中的 MDX-XMLA 查询

SELECT
  NON EMPTY {
    [Measures].[Full price]
  , [Measures].[Promo price]
  } ON COLUMNS,
  NON EMPTY {
    [Items].[Items Hierarchy].[Repo].Members
  , [Items].[Items Hierarchy].[Family].Members
  } ON ROWS
  FROM [MY CUBE]

我在哪里做错了?

4

1 回答 1

0

尝试:

SELECT
  NON EMPTY ({
    [Measures].[Full price]
  , [Measures].[Promo price]
  }) ON COLUMNS,
  NON EMPTY ({
    [Items].[Items Hierarchy].[Repo].Members
  , [Items].[Items Hierarchy].[Family].Members
  }) ON ROWS
  FROM [MY CUBE]
于 2013-08-06T19:12:26.327 回答