当前位置: 首页>>代码示例>>Java>>正文


Java OlapStatement.executeOlapQuery方法代码示例

本文整理汇总了Java中org.olap4j.OlapStatement.executeOlapQuery方法的典型用法代码示例。如果您正苦于以下问题:Java OlapStatement.executeOlapQuery方法的具体用法?Java OlapStatement.executeOlapQuery怎么用?Java OlapStatement.executeOlapQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.olap4j.OlapStatement的用法示例。


在下文中一共展示了OlapStatement.executeOlapQuery方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runQuery

import org.olap4j.OlapStatement; //导入方法依赖的package包/类
/**
 * Executes a query and processes the result using a callback.
 *
 * @param queryString MDX query text
 */
public <T> T runQuery(String queryString, Util.Functor1<T, CellSet> f) {
    long start = System.currentTimeMillis();
    OlapConnection connection = null;
    OlapStatement statement = null;
    CellSet cellSet = null;
    try {
        connection = getOlapConnection();
        statement = connection.createStatement();
        debug("CmdRunner.runQuery: AFTER createStatement");
        start = System.currentTimeMillis();
        cellSet = statement.executeOlapQuery(queryString);
        return f.apply(cellSet);
    } catch (SQLException e) {
        throw new RuntimeException(e);
    } finally {
        queryTime = (System.currentTimeMillis() - start);
        totalQueryTime += queryTime;
        debug("CmdRunner.runQuery: BOTTOM");
        Util.close(cellSet, statement, connection);
    }
}
 
开发者ID:OSBI,项目名称:mondrian,代码行数:27,代码来源:CmdRunner.java

示例2: createDatasource

import org.olap4j.OlapStatement; //导入方法依赖的package包/类
@Override
public JRDataSource createDatasource() throws JRException
{
	
	Properties connectProps = new Properties();
	connectProps.put(XMLA_SERVER, getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_URL));
	connectProps.put(XMLA_CATALOG, getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_CATALOG));
	connectProps.put(XMLA_DATA_SOURCE, getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_DATASOURCE));
	connectProps.put(XMLA_USER, getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_USER));
	connectProps.put(XMLA_PASSWORD, getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_PASSWORD));
	connectProps.put(OLAP4J_DRIVER, OLAP4J_XMLA_DRIVER_CLASS);
	connectProps.put(OLAP4J_URL_PREFIX, OLAP4J_XMLA_URL_PREFIX);
	
	// load driver  and Connection
	rConnection = null;
	try
	{
		Class.forName(OLAP4J_XMLA_DRIVER_CLASS);
		rConnection = java.sql.DriverManager.getConnection(OLAP4J_XMLA_URL_PREFIX, connectProps);
	}
	catch (Throwable t) 
	{
		throw 
			new JRException(
				EXCEPTION_MESSAGE_KEY_CONNECTION_ERROR,
				new Object[]{OLAP4J_XMLA_DRIVER_CLASS},
				t);
	}

	OlapConnection connection = (OlapConnection) rConnection;
	
	/*
	MdxParserFactory pFactory = connection.getParserFactory();
	MdxParser parser = pFactory.createMdxParser(connection);
	SelectNode parsedObject = parser.parseSelect(getQueryString());
	MdxValidator validator = pFactory.createMdxValidator(connection);
	try {
		validator.validateSelect(parsedObject);
	} catch (OlapException e) {
		throw new JRException("Invalid MDX query: " + getQueryString(), e);
	}
	*/
	if (log.isDebugEnabled())
	{
		log.debug("running MDX: " + getQueryString());
	}
	CellSet result = null;
	try
	{
		OlapStatement statement = connection.createStatement();

		result = statement.executeOlapQuery(getQueryString());
	}
	catch (OlapException e)
	{
		throw 
			new JRException(
				EXCEPTION_MESSAGE_KEY_EXECUTE_QUERY_ERROR,
				new Object[]{getQueryString()},
				e);
	}
	
	parseResult(result);
	
	return new JROlapDataSource(dataset, xmlaResult);
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:67,代码来源:Olap4jXmlaQueryExecuter.java

示例3: createDatasource

import org.olap4j.OlapStatement; //导入方法依赖的package包/类
@Override
public JRDataSource createDatasource() throws JRException
{
	JRDataSource dataSource = null;
	
	Properties connectProps = new Properties();
	connectProps.put(OLAP4J_JDBC_DRIVERS, getParameterValue(Olap4jMondrianQueryExecuterFactory.PARAMETER_JDBC_DRIVERS));
	connectProps.put(OLAP4J_JDBC_URL, getParameterValue(Olap4jMondrianQueryExecuterFactory.PARAMETER_JDBC_URL));
	connectProps.put(OLAP4J_JDBC_CATALOG, getParameterValue(Olap4jMondrianQueryExecuterFactory.PARAMETER_CATALOG));
	String user = (String) getParameterValue(Olap4jMondrianQueryExecuterFactory.PARAMETER_JDBC_USER);
	if (user != null) {
		connectProps.put(OLAP4J_JDBC_USER, user);
	}
	String password = (String) getParameterValue(Olap4jMondrianQueryExecuterFactory.PARAMETER_JDBC_PASSWORD);
	if (password != null) {
		connectProps.put(OLAP4J_JDBC_PASSWORD, password);
	}
	connectProps.put(OLAP4J_DRIVER, OLAP4J_MONDRIAN_DRIVER_CLASS);
	connectProps.put(OLAP4J_URL_PREFIX, OLAP4J_MONDRIAN_URL_PREFIX);
	
	// load driver  and Connection
	rConnection = null;
	try
	{
		Class.forName(OLAP4J_MONDRIAN_DRIVER_CLASS);
		rConnection = java.sql.DriverManager.getConnection(OLAP4J_MONDRIAN_URL_PREFIX, connectProps);
	}
	catch (Throwable t)
	{
		throw 
			new JRException(
				EXCEPTION_MESSAGE_KEY_CONNECTION_ERROR,
				new Object[]{OLAP4J_MONDRIAN_DRIVER_CLASS},
				t);
	}

	OlapConnection connection = (OlapConnection) rConnection;
	
	String queryStr = getQueryString();
	if (connection != null && queryStr != null)
	{
		if (log.isDebugEnabled())
		{
			log.debug("MDX query: " + queryStr);
		}
		CellSet result = null;

		try
		{
			OlapStatement statement = connection.createStatement();

			result = statement.executeOlapQuery(getQueryString());
		}
		catch (OlapException e)
		{
			throw 
				new JRException(
					EXCEPTION_MESSAGE_KEY_EXECUTE_QUERY_ERROR,
					new Object[]{getQueryString()},
					e);
		}

		if (log.isDebugEnabled())
		{
			OutputStream bos = new ByteArrayOutputStream();
			CellSetFormatter formatter = new RectangularCellSetFormatter(true);
			formatter.format(result, new PrintWriter(bos, true));
			log.debug("Result:\n" + bos.toString());
		}
		
		dataSource = new Olap4jDataSource(dataset, result);
	}

	return dataSource;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:76,代码来源:Olap4jMondrianQueryExecuter.java

示例4: getResultSet

import org.olap4j.OlapStatement; //导入方法依赖的package包/类
/**
 * 取CellSet
 * 
 * @param connection
 * @param mdx
 * @return
 * @throws OlapException
 * @throws Exception
 */
public static CellSet getResultSet(OlapConnection connection, String mdx) throws OlapException, Exception {
	OlapStatement olapStatement = connection.createStatement();
	CellSet cellSet = olapStatement.executeOlapQuery(mdx);
	return cellSet;
}
 
开发者ID:billchen198318,项目名称:bamboobsc,代码行数:15,代码来源:OlapUtils.java


注:本文中的org.olap4j.OlapStatement.executeOlapQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。