• 获取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);
    	}
    }


  • 相关阅读:
    Wireshark的简介
    Node.js + Express 构建的订餐系统
    java 文件下载支持中文名称
    java判断A字符串中是否包含B字符
    Java查询目录下的所有文件(包括子目录)
    Java从指定URL下载文件并保存到指定目录
    Java逻辑分页代码
    JS实现文字向上无缝滚动轮播
    JAVA调用外部安装7-Zip压缩和解压zip文件
    Zip文件和RAR文件解压
  • 原文地址:https://www.cnblogs.com/pengyan5945/p/5218303.html
Copyright © 2020-2023  润新知