forked from olap4j/olap4j
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a sample class that demonstrates how to connect to Palo with the…
… 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
1 parent
ffc916c
commit 49915ad
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |