zoukankan      html  css  js  c++  java
  • 获取OlapConnection连接

    目录:

    1.获取org.olap4j.OlapConnection对象

    2.获取mondrian.olap.Connection对象


    一、org.olap4j.OlapConnection对象

    说明:先获取jdbc连接(java.sql.Connection);再转换成org.olap4j.OlapConnection。

    package gov.bi.util;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import org.olap4j.OlapConnection;
    
    public class TEST {
    
    	public static void main(String[] args)throws Exception {
    		Class.forName("mondrian.olap4j.MondrianOlap4jDriver");
    		Connection conn = DriverManager.getConnection(
    		    "jdbc:mondrian:" + 
    		    "Jdbc=jdbc:oracle:thin:@10.11.8.173:1521:orcl; " +
    		    "JdbcUser=develop; " +
    		    "JdbcPassword=123; " +
    		    "Catalog=file:E:\cube_xml\91dd93f.xml; " +
    		    "JdbcDrivers=oracle.jdbc.driver.OracleDriver");
    		OlapConnection olapConn = conn.unwrap(OlapConnection.class);
    		System.out.println(olapConn);
    	}
    }


    二、获取mondrian.olap.Connection对象

    package gov.bi.util;
    
    import mondrian.olap.Connection;
    import mondrian.olap.DriverManager;
    import mondrian.olap.Util.PropertyList;
    import mondrian.spi.CatalogLocator;
    import mondrian.spi.impl.CatalogLocatorImpl;
    
    public class T {
    	public static void main(String[] args) throws Exception{
    		// 加载MondrianOlap4jDriver驱动
    		Class.forName("mondrian.olap4j.MondrianOlap4jDriver");
    		PropertyList propList = new PropertyList();
    		propList.put("Provider", "mondrian");// 必须是mondrian
    		propList.put("Catalog", "e:\abc.xml");// cube文件路径
    		//jdbc相关信息
    		propList.put("JdbcDrivers", "oracle.jdbc.driver.OracleDriver");
    		propList.put("Jdbc", "jdbc:oracle:thin:@10.11.8.173:1521:orcl");
    		propList.put("JdbcUser","develop");
    		propList.put("JdbcPassword","admin");
    		// cube文件
    		CatalogLocator locator = new CatalogLocatorImpl();
    		locator.locate("e:\abc.xml");
    		Connection connection = DriverManager.getConnection(propList, locator);
    	}
    }


  • 相关阅读:
    背包系列 hdu3449 有依赖背包
    背包系列 hdu 3535 分组背包
    屏蔽scrollview的滚动
    高精度算法代码
    输入法出现时,中间固定,底部上移的代码
    排序之分治排序
    排序之双向冒泡排序
    Miller Rabin 大素数测试
    来聊聊WWDC 苹果大会上的那些黑科技
    不想成为好leader的程序猿不是好攻城狮
  • 原文地址:https://www.cnblogs.com/pengyan5945/p/5218303.html
Copyright © 2011-2022 走看看