Skip to content

Commit

Permalink
Adds a sample class that demonstrates how to connect to Palo with the…
Browse files Browse the repository at this point in the history
… XML/A server. Original post is at http://sourceforge.net/projects/olap4j/forums/forum/577988/topic/3787499

Thanks to Vladislav Malicevic for this contribution.

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@330 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
lucboudreau committed Jul 28, 2010
1 parent ffc916c commit 49915ad
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions src/org/olap4j/sample/PaloConnection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
// $Id:$
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2006-2010 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package org.olap4j.sample;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;

import org.olap4j.CellSet;
import org.olap4j.OlapConnection;
import org.olap4j.OlapStatement;
import org.olap4j.OlapWrapper;
import org.olap4j.driver.xmla.XmlaOlap4jDriver;
import org.olap4j.layout.TraditionalCellSetFormatter;

/**
* This class demonstrates how to connect the {@link XmlaOlap4jDriver}
* to a Palo server. Thanks to Vladislav Malicevic for this
* contribution.
* @author Luc Boudreau
*/
public class PaloConnection {

public static void main(String[] args) throws Exception {
Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
Connection connection =
DriverManager.getConnection(
"jdbc:xmla:Server=http://localhost:4242;"
+ "User='admin';"
+ "Password='admin';"
+ "Catalog=FoodMart2005Palo;"
+ "Cube=Budget");

OlapWrapper wrapper = (OlapWrapper) connection;

OlapConnection olapConnection = wrapper.unwrap(OlapConnection.class);

OlapStatement statement = olapConnection.createStatement();

CellSet cellSet =
statement.executeOlapQuery(
"SELECT {[store].[USA]} ON COLUMNS , {[Account].[1000]} ON ROWS\n"
+ "FROM [Budget]");

TraditionalCellSetFormatter formatter =
new TraditionalCellSetFormatter();

formatter.format(cellSet, new PrintWriter(System.out));
}
}

// End PaloConnection.java

0 comments on commit 49915ad

Please sign in to comment.