尝试连接到SSAS多维数据集时出现异常?

时间:2014-01-15 09:39:19

标签: java ssas olap4j

当我尝试使用olap4j驱动程序连接SSAS多维数据集时,这个例外刚刚出来,并且在互联网上搜索,只是无法获取任何信息! 异常输出如下:

Exception in thread "main" java.lang.NoClassDefFoundError: com/rc/retroweaver/runtime/Collections
    at org.olap4j.driver.xmla.XmlaOlap4jDriver.<clinit>(XmlaOlap4jDriver.java:338)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at cn.lds.olap.T.getConnection(T.java:19)
    at cn.lds.olap.T.main(T.java:30)
Caused by: java.lang.ClassNotFoundException: com.rc.retroweaver.runtime.Collections
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 5 more

这是我的java代码: package cn.lds.olap;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import org.olap4j.Cell;
import org.olap4j.CellSet;
import org.olap4j.OlapConnection;
import org.olap4j.OlapStatement;
import org.olap4j.OlapWrapper;
import org.olap4j.Position;
import org.olap4j.metadata.Member;

public class T {
    public static Connection getConnection() {
        Connection connection = null;
        try {
            Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
            connection = DriverManager
                    .getConnection("jdbc:xmla:Server=http://localhost/olap/msmdpump.dll;Catalog=CubeOne");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return connection;
    }

    public static void main(String[] args) {
        try {
            Connection connection = getConnection();
            OlapWrapper wrapper = (OlapWrapper) connection;
            OlapConnection olapConnection = wrapper
                    .unwrap(OlapConnection.class);
            OlapStatement statement = (OlapStatement) connection
                    .createStatement();
            CellSet cellSet = statement
                    .executeOlapQuery("SELECT {[Measures].[Unit Sales]} ON COLUMNS,\n"
                            + "  {[Product].Members} ON ROWS\n"
                            + "FROM [Adventure Works DW2012]");
            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 (Exception e) {
            e.printStackTrace();
        }
    }

}

我使用的是jdk1.6.0_45,而olap4j的版本是1.1.0。

1 个答案:

答案 0 :(得分:2)

我敢打赌你的类路径中有olap4j和olap4j-jdk14。删除olap4j-jdk14,因为这仅适用于1.4及以下的JVM。你不能同时使用它们。