1

I have a data source which has a provider MSOLAP I want to connect to this source via java based application. I used the following:

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();
}

I get the class OlapConnection is not compiled. I have two questions: 1- I am using maven to build this test and it is not showing errors why would this class not be found?

2- is there any other way to connect to MSOLAP without using olap4j?

Muhammad Bekette
  • 1,396
  • 1
  • 24
  • 60

1 Answers1

1

This isn't how you connect remotely to an XMLA service. Start by reading this code, and then you'll need to edit the connection string.

In SSAS, the connection string should look something like this:

jdbc:xmla:Server=http://localhost/olap/msmdpump.dll;Catalog=myCatalog
Luc
  • 672
  • 3
  • 8
  • I have tried the example you indicated but still the maven dependency could not provide OlapConnection class. I updated the code – Muhammad Bekette May 06 '14 at 12:48
  • If your problem is with Maven, then that's a separate issue, not related to olap4j at all. I'd recommend making sure that you're including both org.olap4j:olap4j and org.olap4j:olap4j-xmla as dependencies. – Luc May 06 '14 at 15:01