本文整理汇总了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;
}
示例2: prepareOlapStatement
import org.olap4j.PreparedOlapStatement; //导入依赖的package包/类
@Override
public PreparedOlapStatement prepareOlapStatement(String mdx)
throws OlapException {
return new ServerPreparedOlapStatement(this, mdx);
}
示例3: createPreparedStatement
import org.olap4j.PreparedOlapStatement; //导入依赖的package包/类
public PreparedOlapStatement createPreparedStatement(
Olap4jDataSource dataSource,
String mdx,
SPVariableHelper helper);
示例4: createPreparedStatement
import org.olap4j.PreparedOlapStatement; //导入依赖的package包/类
public PreparedOlapStatement createPreparedStatement(
Olap4jDataSource dataSource, String mdx, SPVariableHelper helper) {
return delegateContext.createPreparedStatement(dataSource, mdx, helper);
}