无法使用olap4j连接到XMLA / Mondrian

问题描述 投票:0回答:1

我正在尝试通过java api(olap4j)连接到XMLA webservice,以便在Mondrian cube上执行MDX查询,该多维数据集位于localhost中托管的BI工具中。

这是我的代码如下:

 try {
         Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
         Connection connection =
                DriverManager.getConnection(
                        "jdbc:xmla:Server=http://127.0.0.1:8080/jasperserver-pro/xmla");



        OlapWrapper wrapper = (OlapWrapper) connection;
        OlapConnection olapConnection = wrapper
                .unwrap(OlapConnection.class);
        OlapStatement statement = (OlapStatement) connection
                .createStatement();

        CellSet cellSet =
                statement.executeOlapQuery("select [Measures].Members ON COLUMNS\n" +
                        "from [FAIS_MED]\n");
        for (Position row : cellSet.getAxes().get(1)) {
            for (Position column : cellSet.getAxes().get(0)) {
                for (Member member : row.getMembers()) {
                    System.out.println(member.getUniqueName());
                }
                for (Member member : column.getMembers()) {
                    System.out.println(member.getUniqueName());
                }
                final Cell cell = cellSet.getCell(column, row);
                System.out.println(cell.getFormattedValue());
                System.out.println();
            }
        }


        } catch (SQLException | ClassNotFoundException e) {
        e.printStackTrace();
    }

我会得到以下错误:

java.lang.ClassNotFoundException: org.olap4j.driver.xmla.XmlaOlap4jDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.slimani.bi_restful.testing.MondrianOlap4jDriver.getConnection(MondrianOlap4jDriver.java:18)
at com.slimani.bi_restful.testing.MondrianOlap4jDriver.main(MondrianOlap4jDriver.java:45)
Exception in thread "main" java.lang.NullPointerException at com.slimani.bi_restful.testing.MondrianOlap4jDriver.main(MondrianOlap4jDriver.java:48)
java mdx mondrian xmla olap4j
1个回答
0
投票

找不到XMLA驱动程序。您可以在java.lang.ClassNotFoundException中看到这一点:org.olap4j.driver.xmla.XmlaOlap4jDriver。

你可以从maven:https://mvnrepository.com/artifact/org.olap4j/olap4j-xmla/1.2.0下载它

© www.soinside.com 2019 - 2024. All rights reserved.