将MS OLAP与Java连接

时间:2014-04-30 11:16:52

标签: java olap olap-cube olap4j

我有一个数据源,它有一个提供者MSOLAP我想通过基于java的应用程序连接到这个源。我使用了以下内容:

public static void main(String[] args) throws Exception {

    // Load the driver
    Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");

    // Connect
    final Connection connection =
            DriverManager.getConnection(
                // This is the SQL Server service end point.
                "jdbc:xmla:Server=http://localhost:81/mondrian/xmla"

                // Tells the XMLA driver to use a SOAP request cache layer.
                // We will use an in-memory static cache.
                + ";Cache=org.olap4j.driver.xmla.cache.XmlaOlap4jNamedMemoryCache"

                // Sets the cache name to use. This allows cross-connection
                // cache sharing. Don't give the driver a cache name and it
                // disables sharing.
                + ";Cache.Name=MyNiftyConnection"

                            // Some cache performance tweaks.
                            // Look at the javadoc for details.
                            + ";Cache.Mode=LFU;Cache.Timeout=600;Cache.Size=100",

                    // XMLA is over HTTP, so BASIC authentication is used.
                    null,
                    null);

    // We are dealing with an olap connection. we must unwrap it.
    final OlapConnection olapConnection = connection.unwrap(OlapConnection.class);

    // Check if it's all groovy
    ResultSet databases = olapConnection.getMetaData().getDatabases();
    databases.first();
    System.out.println(
            olapConnection.getMetaData().getDriverName()
                    + " -> "
                    + databases.getString(1));

    // Done
    connection.close();
}

我得到的课程OlapConnection未编译。我有两个问题:1-我正在使用maven来构建这个测试并且没有显示错误为什么不能找到这个类?

2-有没有其他方法可以连接到MSOLAP而不使用olap4j?

1 个答案:

答案 0 :(得分:1)

这不是您远程连接到XMLA服务的方式。首先阅读this code,然后您需要编辑连接字符串。

在SSAS中,连接字符串应如下所示:

jdbc:xmla:Server=http://localhost/olap/msmdpump.dll;Catalog=myCatalog