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


Java OlapStatement类代码示例

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


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

示例1: testCannedProcedure

import org.olap4j.OlapStatement; //导入依赖的package包/类
@Test public void testCannedProcedure() throws Exception {
	String ddl = "create foreign procedure proc(arg integer, arg1 date) returns table (x string) options (\"teiid_rel:native-query\" '$2 $1 something')";
	String query = "exec proc(2, {d'1970-01-01'})";
	
	TransformationMetadata tm = RealMetadataFactory.fromDDL(ddl, "x", "phy");
	
	CommandBuilder commandBuilder = new CommandBuilder(tm);
       Command obj = commandBuilder.getCommand(query);
        
	OlapExecutionFactory oef = new OlapExecutionFactory();
	Connection mock = Mockito.mock(java.sql.Connection.class);
	OlapWrapper mock2 = Mockito.mock(OlapWrapper.class);
	OlapConnection mock3 = Mockito.mock(OlapConnection.class);
	OlapStatement mock4 = Mockito.mock(OlapStatement.class);
	Mockito.stub(mock4.executeOlapQuery(Mockito.anyString())).toThrow(new TeiidRuntimeException());
	Mockito.stub(mock3.createStatement()).toReturn(mock4);
	Mockito.stub(mock2.unwrap(OlapConnection.class)).toReturn(mock3);
	Mockito.stub(mock.unwrap(OlapWrapper.class)).toReturn(mock2);
	ProcedureExecution pe = oef.createProcedureExecution((Call)obj, Mockito.mock(ExecutionContext.class), new RuntimeMetadataImpl(tm), mock);
	try {
		pe.execute();
		fail();
	} catch (TeiidRuntimeException e) {
		Mockito.verify(mock4).executeOlapQuery("'1970-01-01' 2 something");
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:27,代码来源:TestOlapTranslator.java

示例2: 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

示例3: cancel

import org.olap4j.OlapStatement; //导入依赖的package包/类
@Override
public void cancel() throws TranslatorException {
	try {
		OlapStatement olapStatement = this.stmt;
		if (olapStatement != null) {
			olapStatement.cancel();
		}
	} catch (SQLException e) {
		throw new TranslatorException(e);
	}		
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:12,代码来源:OlapQueryExecution.java

示例4: setStatementProfiling

import org.olap4j.OlapStatement; //导入依赖的package包/类
public void setStatementProfiling(
    OlapStatement statement,
    final PrintWriter pw)
{
    ((MondrianOlap4jStatement) statement).enableProfiling(
        new ProfileHandler() {
            public void explain(String plan, QueryTiming timing) {
                pw.println(plan);
                if (timing != null) {
                    pw.println(timing);
                }
            }
        }
    );
}
 
开发者ID:OSBI,项目名称:mondrian,代码行数:16,代码来源:Unsafe.java

示例5: createStatement

import org.olap4j.OlapStatement; //导入依赖的package包/类
@Override
public OlapStatement createStatement() throws OlapException {
	return new ServerOlapStatement(this);
}
 
开发者ID:Wondersoft,项目名称:olaper,代码行数:5,代码来源:ServerConnection.java

示例6: ServerCellSet

import org.olap4j.OlapStatement; //导入依赖的package包/类
public ServerCellSet(OlapStatement olapStatement, Cube cube) {
	this.olapStatement = olapStatement;
	this.cube = cube;
}
 
开发者ID:Wondersoft,项目名称:olaper,代码行数:5,代码来源:ServerCellSet.java

示例7: getStatement

import org.olap4j.OlapStatement; //导入依赖的package包/类
@Override
public OlapStatement getStatement() throws SQLException {
	return olapStatement;
}
 
开发者ID:Wondersoft,项目名称:olaper,代码行数:5,代码来源:ServerCellSet.java

示例8: 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

示例9: 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

示例10: createStatement

import org.olap4j.OlapStatement; //导入依赖的package包/类
public OlapStatement createStatement() {
    return super.createStatement();
}
 
开发者ID:Twixer,项目名称:mondrian-3.1.5,代码行数:4,代码来源:FactoryJdbc4Impl.java

示例11: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。