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


Java PreparedOlapStatement类代码示例

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


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

示例1: substituteForDb

import org.olap4j.PreparedOlapStatement; //导入依赖的package包/类
/**
 * Helper method that takes a connection and a MDX statement which includes variable and 
 * converts all that in a nifty prepared statement ready for execution, on time for Christmas.
 * @param connection A connection object to use in order to generate the prepared statement.
 * @param sql A MDX string which might include variables.
 * @param variableHelper A {@link SPVariableHelper} object to resolve the variables.
 * @return A {@link PreparedStatement} object ready for execution.
 * @throws SQLException Might get thrown if we cannot generate a {@link PreparedStatement} with the supplied connection.
 */
public static PreparedOlapStatement substituteForDb(
		OlapConnection connection, 
		String mdxQuery, 
		SPVariableHelper variableHelper) throws SQLException 
{
	
	// Make sure that the registry is ready.
    SPResolverRegistry.init(variableHelper.getContextSource());
    
    StringBuilder text = new StringBuilder();
    Matcher matcher = varPattern.matcher(mdxQuery);
    List<Object> vars = new LinkedList<Object>();
    
    // First, change all vars to '?' markers.
    int currentIndex = 0;
    while (!matcher.hitEnd()) {
        if (matcher.find()) {
            String variableName = matcher.group(1);
            if (variableName.equals("$")) {
            	vars.add("$");
            } else {
            	vars.add(variableHelper.resolve(variableName));
            }
            text.append(mdxQuery.substring(currentIndex, matcher.start()));
            text.append("?");
            currentIndex = matcher.end();
        }  
    }
    text.append(mdxQuery.substring(currentIndex));
    
    // Now generate a prepared statement and inject it's variables.
    PreparedOlapStatement ps = connection.prepareOlapStatement(text.toString());
    for (int i = 0; i < vars.size(); i++) {
		ps.setObject(i+1, vars.get(i));
    }
    
    return ps;
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:48,代码来源:SPVariableHelper.java

示例2: prepareOlapStatement

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

示例3: createPreparedStatement

import org.olap4j.PreparedOlapStatement; //导入依赖的package包/类
public PreparedOlapStatement createPreparedStatement(
Olap4jDataSource dataSource,
String mdx,
SPVariableHelper helper);
 
开发者ID:SQLPower,项目名称:wabit,代码行数:5,代码来源:OlapConnectionProvider.java

示例4: createPreparedStatement

import org.olap4j.PreparedOlapStatement; //导入依赖的package包/类
public PreparedOlapStatement createPreparedStatement(
		Olap4jDataSource dataSource, String mdx, SPVariableHelper helper) {
	return delegateContext.createPreparedStatement(dataSource, mdx, helper);
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:5,代码来源:WabitSwingSessionContextImpl.java


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