0

I wrote a java class with the main() method to connect to "msmdpump.dll" and execute MDX on cube and retrieve a result. like this :

    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://172.20.0.29:80/OLAP/msmdpump.dll"+
                ";Catalog=CreditCard", 
                "", 
                "");


    } catch (SQLException e) {
        e.printStackTrace();
    }
    if (null== connection){
        System.out.println("Connection null");
    }else
        System.out.println("Connect Successfully !");

    OlapWrapper wrapper = (OlapWrapper) connection;
    OlapConnection olapConnection = null;
    try {
    olapConnection = wrapper.unwrap(OlapConnection.class);
    } catch (SQLException e) {
    e.printStackTrace();
    }
    OlapStatement statement = null;
    CellSet cellSet = null;
    try {
    statement = (OlapStatement) olapConnection.createStatement();
    cellSet =   statement.executeOlapQuery(

          "SELECT NON EMPTY { [Measures].[Instalment Future Amount] } ON COLUMNS"+
          ", NON EMPTY { ([Dim MerchantInstalmentCashFlowDate].[J Year].[J Year].ALLMEMBERS * [Dim MerchantInstalmentCashFlowDate].[Persian Month].[Persian Month].ALLMEMBERS) }  ON ROWS "+ 
          "FROM [Credit Card DW] where ([Dim Merchant].[Mrc Unique Id].[Mrc Unique Id].&[100000000000013])"     

    );

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

    for (Position row : cellSet.getAxes().get(1)) {
        for (Position column : cellSet.getAxes().get(0)) {
                for (Member member : row.getMembers()) {
                        System.out.println(member.getName());
                }
                final Cell cell = cellSet.getCell(column, row);
                System.out.println(cell.getFormattedValue());
                System.out.println();

        }

    }
}

everything is fine, I executed it on my local computer and see the result on my console :)

Next I copied the same code in my backbean's method to call it from jsf page. I deployed the EAR file contained those pages and when I brows that jsf on browser I got this error which means the application doesn't have authorize to connect to .dll file !!

'401: Unauthorized' for url: http:// 172.20.0.29:80/OLAP/msmdpump.dll

All code is same and only the different is I execute the first class by java (with main() method) and in second I call the method by jsf which deployed on Weblogic.

Any body could help me to figure it out why this happen ? Thanks in advance .

soheilz92
  • 127
  • 2
  • 19

1 Answers1

0

You are passing an empty username and password when you call into the driver manager. This results in an HTTP 401 error. Verify who can connect to this URL, what their credentials are and pass them to the call to getconnection.

Luc
  • 672
  • 3
  • 8
  • Thanks @Lus , but the thing is when I execute the core java class it works (same connection) and there was no such unauthorized error. In other hand I tested all authorized option in IIS like windows , basic, anonymous and etc, but none of them were work :( – soheilz92 May 08 '14 at 04:12