connect to SSAS using olap4j on Linux machine (Ubuntu14.04)

anjali
2014-08-28
2014-09-02
  • anjali

    anjali - 2014-08-28

    I wish to connect to SSAS 2012 using Java and have tried olap4j driver for the same.
    I am working on Linux (Ubuntu 14.04) platform.

    I have read that Olap4j works for Windows but will it work on Linux ?

    I have written a java code which gives run time error. This error is because Linux pc is unable to connect to SSAS.
    May you please help me finding the reason of not being able to connect ?

    I have set http access and IIS server and using msmdpump.dll to connect.

    Below is the java code and the error.

    CODE

    package ssas;
    import java.sql.Connection;
    //import java.lang.*;
    import java.sql.DriverManager;
    import java.sql.SQLException;

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

    public class connexionSSAS
    {
    public static void main(String[] args) throws ClassNotFoundException, OlapException {

    Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
    
    Connection connection = null;
    try{
    connection = DriverManager.getConnection("jdbc:xmla:Server=http://01XXXXXXXX/olap/msmdpump.dll;"
                                                        + "Catalog=sample_Cube");
    
    }catch (SQLException e)
    {
        e.printStackTrace();
    }
    
    if (null== connection){
        System.out.println("Cnul");
        }
    
    OlapWrapper wrapper = (OlapWrapper) connection;
    OlapConnection olapConnection = null;
    try {
    olapConnection = wrapper.unwrap(OlapConnection.class);
    } catch (SQLException e) {
    e.printStackTrace();
    }
    
    olapConnection.setCatalog("sample_Cube");
    OlapStatement statement = null;
    CellSet cellSet = null;
    
    System.out.println(olapConnection.getCatalog());
    
    try {
    statement = (OlapStatement) olapConnection.createStatement();
    
    CellSet=statement.executeOlapQuery("Summarize(FactDiagnosis,FactDiagnosis[ImportDateKey])");
    args}    
    catch(SQLException e)
    {
        e.printStackTrace();
    }
    
    }
    

    }

    ERROR

    Exception in thread "main" java.lang.RuntimeException: org.olap4j.OlapException: This connection encountered an exception while executing a query.
    at org.olap4j.driver.xmla.DeferredNamedListImpl.getList(DeferredNamedListImpl.java:96)
    at org.olap4j.driver.xmla.DeferredNamedListImpl.size(DeferredNamedListImpl.java:116)
    at org.olap4j.driver.xmla.XmlaOlap4jConnection.getOlapDatabase(XmlaOlap4jConnection.java:451)
    at org.olap4j.driver.xmla.XmlaOlap4jConnection.getOlapCatalogs(XmlaOlap4jConnection.java:527)
    at org.olap4j.driver.xmla.XmlaOlap4jConnection.setCatalog(XmlaOlap4jConnection.java:483)
    at ssas.connexionSSAS.main(connexionSSAS.java:49)
    Caused by: org.olap4j.OlapException: This connection encountered an exception while executing a query.
    at org.olap4j.driver.xmla.XmlaHelper.createException(XmlaHelper.java:43)
    at org.olap4j.driver.xmla.XmlaOlap4jConnection.executeMetadataRequest(XmlaOlap4jConnection.java:878)
    at org.olap4j.driver.xmla.XmlaOlap4jDatabaseMetaData.getMetadata(XmlaOlap4jDatabaseMetaData.java:137)
    at org.olap4j.driver.xmla.XmlaOlap4jDatabaseMetaData.getMetadata(XmlaOlap4jDatabaseMetaData.java:67)
    at org.olap4j.driver.xmla.XmlaOlap4jDatabaseMetaData.getDatabaseProperties(XmlaOlap4jDatabaseMetaData.java:1044)
    at org.olap4j.driver.xmla.XmlaOlap4jConnection.makeConnectionPropertyList(XmlaOlap4jConnection.java:324)
    at org.olap4j.driver.xmla.XmlaOlap4jConnection.generateRequest(XmlaOlap4jConnection.java:1037)
    at org.olap4j.driver.xmla.XmlaOlap4jConnection.populateList(XmlaOlap4jConnection.java:849)
    at org.olap4j.driver.xmla.DeferredNamedListImpl.populateList(DeferredNamedListImpl.java:136)
    at org.olap4j.driver.xmla.DeferredNamedListImpl.getList(DeferredNamedListImpl.java:90)
    ... 5 more

    This code will run if I comment the statements containing 'OlapConnection'.
    Any help would be appreciated.

     
    • Julian Hyde

      Julian Hyde - 2014-08-28

      The exception seems to occur when you call setCatalog. Is “sample_Cube” a valid catalog name?

      Julian

       
      • anjali

        anjali - 2014-09-01

        Yes Julian. The cube name is valid which is present in the analysis server. I have access to that cube as well.
        Is this problem occurring because I am using Linux ?

         
    • Julian Hyde

      Julian Hyde - 2014-09-02

      I doubt that it's because you're on Linux. The code behaves pretty much the same on all operating systems.

      I'll repeat my question.

      Is "sample_Cube" a valid catalog name? (Catalog names are case-sensitive. Catalog names are not cube names.)

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks