Integration of Mondrian and Java engineering

Source: Internet
Author: User

Mondrian is a standalone engine that is typically used in a way that is embedded in the application, simply by adding a class library to the classpath. There are actually multiple sets of BI solutions that are integrated Mondrian to achieve multidimensional analysis.
This article describes how to programmatically connect Mondrian and execute MDX queries. Using Mondrian requires a connection to the database and a description file for the multidimensional data (Schema file). This can be learned through my previous article.

http://blog.csdn.net/qzp1991/article/details/44016959

http://blog.csdn.net/qzp1991/article/details/44017161

First, Prerequisites:

1.JDK environment configuration is completed;

2. Complete the deployment of Mondrian servers and multidimensional databases under Tomcat;

Instance of the building, which in my previous article had involved

http://blog.csdn.net/qzp1991/article/details/44016959

Second, the establishment of Java engineering

1. Import the Mondrian Essentials package

They're in mondrian\web-inf\lib.

2. Import the driver connected to MySQL

3. Writing the relevant core code

Package Mondrian.java.api;import Java.io.printwriter;import Mondrian.olap.connection;import Mondrian.olap.drivermanager;import Mondrian.olap.query;import Mondrian.olap.result;public class Main {  @ Suppresswarnings ("deprecation") public static void main (string[] args) {  Connection Connection = Drivermanager.getconnection (  "Provider=mondrian; jdbc=jdbc:mysql://localhost/nts_eway_ee?user=root&password=root;        catalog=e:/apache-tomcat-7.0.40/webapps/mondrian/web-inf/queries/ntsdw.xml; ", null);  Query Query =connection.parsequery ("SELECT {[measures].[ Nts_sample]} on COLUMNS,              {[region.default].[ Allregion],[region.default]. [Jiangsu], [Region.default]. [Hunan]} On ROWS from               [Ntsdw] where [time.default].[ 2015]. [1]. [1] ");  result = Connection.Execute (query);        PrintWriter pw = new PrintWriter (system.out);        Result.print (PW);        Pw.flush ();}}
Related explanations

The Mondrian itself performs an MDX query on the interface that is located in the Mondrian.olap package.

Jdbc=jdbc:mysql://localhost/nts_eway_ee?user=root&password=root
Represents the name of the connection database and the associated user name and password

Catalog=e:/apache-tomcat-7.0.40/webapps/mondrian/web-inf/queries/ntsdw.xml;
Indicates where the schema file is located

Query Query =connection.parsequery ("SELECT {[measures].[ Nts_sample]} on COLUMNS,              {[region.default].[ Allregion],[region.default]. [Jiangsu], [Region.default]. [Hunan]} On ROWS from               [Ntsdw] where [time.default].[ 2015]. [1]. [1] ");
Represents the specific MDX execution statement

Result is the return value of an MDX execution statement

Where thePw.flush () statement is required, otherwise it will not be output

Click Run to execute the results as follows:


Mondrian integration with Java engineering

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.