本文整理汇总了Java中mondrian.olap.DriverManager类的典型用法代码示例。如果您正苦于以下问题:Java DriverManager类的具体用法?Java DriverManager怎么用?Java DriverManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DriverManager类属于mondrian.olap包,在下文中一共展示了DriverManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConnection
import mondrian.olap.DriverManager; //导入依赖的package包/类
private static Connection getConnection(String propertiesFileName) throws FileNotFoundException, IOException
{
if (propertiesFileName == null) {
throw new RuntimeException("connection properties file not set");
}
ConnectionData data = getConnectionData(propertiesFileName);
Connection connection = null;
if (data.isEnabled())
{
connection =
DriverManager.getConnection(
"Provider=mondrian;" +
"JdbcDrivers=" + data.getJdbcDrivers() + ";" +
"Jdbc=" + data.getJdbcUrl() + ";" +
"JdbcUser=" + data.getJdbcUser() + ";" +
"JdbcPassword=" + data.getJdbcPassword() + ";" +
"Catalog=" + data.getCatalogUri() + ";",
null
);
}
return connection;
}
示例2: contributeParameters
import mondrian.olap.DriverManager; //导入依赖的package包/类
@Override
public void contributeParameters(Map<String, Object> parameters)
throws JRException {
MondrianDataAdapter mda = getJdbcDataAdapter();
if (mda != null) {
Util.PropertyList props = new Util.PropertyList();
props.put("Catalog", mda.getCatalogURI());
props.put("Provider", "mondrian");
props.put("Locale", Locale.getDefault().getLanguage());
connection = DriverManager.getConnection(props, null,
new SimpleSQLDataSource(this));
parameters
.put(JRMondrianQueryExecuterFactory.PARAMETER_MONDRIAN_CONNECTION,
connection);
}
}
示例3: getOlap4jConnection
import mondrian.olap.DriverManager; //导入依赖的package包/类
public OlapConnection getOlap4jConnection() throws SQLException {
try {
Class.forName("mondrian.olap4j.MondrianOlap4jDriver");
} catch (ClassNotFoundException e) {
throw new RuntimeException("Driver not found");
}
String connectString = getConnectString();
if (connectString.startsWith("Provider=mondrian; ")) {
connectString =
connectString.substring("Provider=mondrian; ".length());
}
final java.sql.Connection connection =
java.sql.DriverManager.getConnection(
"jdbc:mondrian:" + connectString);
return ((OlapWrapper) connection).unwrap(OlapConnection.class);
}
示例4: openQuery
import mondrian.olap.DriverManager; //导入依赖的package包/类
public void openQuery() throws KettleDatabaseException {
String connectString = "Provider=mondrian;" +
"Jdbc='"+space.environmentSubstitute(databaseMeta.getURL())+"';"+
"Catalog='"+space.environmentSubstitute(catalog)+"';"+
"JdbcDrivers="+space.environmentSubstitute(databaseMeta.getDriverClass())+";";
if (!Const.isEmpty(databaseMeta.getUsername())) {
connectString+="JdbcUser="+space.environmentSubstitute(databaseMeta.getUsername())+";";
}
if (!Const.isEmpty(databaseMeta.getPassword())) {
connectString+="JdbcPassword="+space.environmentSubstitute(databaseMeta.getPassword())+";";
}
connection = DriverManager.getConnection(connectString, null);
query = connection.parseQuery(queryString);
result = connection.execute(query);
}
示例5: loadConvertedSchemaInMondrian
import mondrian.olap.DriverManager; //导入依赖的package包/类
@Test
public void loadConvertedSchemaInMondrian() throws Exception {
// temp file to hold conversion output
File tmpFile = File.createTempFile("output_foodmart_", ".xml"); //$NON-NLS-1$ //$NON-NLS-2$
// do conversion on SSAS dump of foodmart
List<Document> docs = ConversionUtil.generateMondrianDocsFromSSASSchema(getClass().getResourceAsStream(
"/analysis_server_output.xml")); //$NON-NLS-1$
// save conversion to file
FileUtils.writeStringToFile(tmpFile, docs.get(0).asXML());
// load file into Mondrian
String connectString = getTestProperty("test.mondrian.foodmart.connectString", //$NON-NLS-1$
getTestProperty("test.mondrian.foodmart.connectString.provider"), //$NON-NLS-1$
getTestProperty("test.mondrian.foodmart.connectString.jdbc"), //$NON-NLS-1$
getTestProperty("test.mondrian.foodmart.connectString.username"), //$NON-NLS-1$
getTestProperty("test.mondrian.foodmart.connectString.password"), //$NON-NLS-1$
tmpFile.getPath());
DriverManager.getConnection(connectString, null).getSchema();
}
示例6: getConnection
import mondrian.olap.DriverManager; //导入依赖的package包/类
/**
* Gets a Mondrian connection, creating a new one if fresh is true.
*
* @return mondrian Connection.
*/
public synchronized Connection getConnection(boolean fresh) {
// FIXME: fresh is currently ignored.
if (this.connectString == null) {
makeConnectString();
}
if (this.connection == null) {
this.connection =
DriverManager.getConnection(this.connectString, null);
}
return this.connection;
}
示例7: getOlapConnection
import mondrian.olap.DriverManager; //导入依赖的package包/类
/**
* Gets an olap4j connection, creating a new one if fresh is true.
*
* @return mondrian Connection.
*/
public synchronized OlapConnection getOlapConnection() throws SQLException {
if (this.connectString == null) {
makeConnectString();
}
final String olapConnectString = "jdbc:mondrian:" + connectString;
final java.sql.Connection jdbcConnection =
java.sql.DriverManager.getConnection(olapConnectString);
// Cast to OlapWrapper lets code work on JDK1.5, before java.sql.Wrapper
//noinspection RedundantCast
return ((OlapWrapper) jdbcConnection).unwrap(OlapConnection.class);
}
示例8: getConnection
import mondrian.olap.DriverManager; //导入依赖的package包/类
OlapConnection getConnection(
CatalogInfo catalogInfo,
MondrianServer server,
String roleName,
Properties props)
throws SQLException
{
String connectString = catalogInfo.olap4jConnectString;
// Save the server for the duration of the call to 'getConnection'.
final LockBox.Entry entry =
MondrianServerRegistry.INSTANCE.lockBox.register(server);
final Properties properties = new Properties();
properties.setProperty(
RolapConnectionProperties.Instance.name(),
entry.getMoniker());
if (roleName != null) {
properties.setProperty(
RolapConnectionProperties.Role.name(),
roleName);
}
properties.putAll(props);
// Make sure we load the Mondrian driver into
// the ClassLoader.
try {
ClassResolver.INSTANCE.forName(
MondrianOlap4jDriver.class.getName(), true);
} catch (ClassNotFoundException e) {
throw new OlapException("Cannot find mondrian olap4j driver.");
}
final java.sql.Connection connection =
java.sql.DriverManager.getConnection(connectString, properties);
return ((OlapWrapper) connection).unwrap(OlapConnection.class);
}
示例9: checkSchemaFile
import mondrian.olap.DriverManager; //导入依赖的package包/类
/**
* Check if schema file is valid by initiating a mondrian connection.
*/
private void checkSchemaFile(File file) {
try {
// this connection parses the catalog file which if invalid will
// throw exception
PropertyList list = new PropertyList();
list.put("Provider", "mondrian");
list.put("Jdbc", jdbcConnectionUrl);
list.put("Catalog", file.toURI().toURL().toString());
list.put("JdbcDrivers", jdbcDriverClassName);
if (jdbcUsername != null && jdbcUsername.length() > 0) {
list.put("JdbcUser", jdbcUsername);
}
if (jdbcPassword != null && jdbcPassword.length() > 0) {
list.put("JdbcPassword", jdbcPassword);
}
DriverManager.getConnection(list, null);
} catch (Exception ex) {
LOGGER.error(
"Exception : Schema file "
+ file.getAbsolutePath()
+ " is invalid."
+ ex.getMessage(), ex);
} catch (Error err) {
LOGGER.error(
"Error : Schema file "
+ file.getAbsolutePath()
+ " is invalid."
+ err.getMessage(), err);
}
}
示例10: testSchema3withVersion
import mondrian.olap.DriverManager; //导入依赖的package包/类
public void testSchema3withVersion() {
TestContext testContext =
TestContext.instance().withSchema(SCHEMA_3_VHEADER + SCHEMA_3_BODY);
Util.PropertyList connectInfo =
testContext.getConnectionProperties();
Connection conn = DriverManager.getConnection(connectInfo, null);
assertNotNull(conn);
conn.close();
}
示例11: testSchema3noVersion
import mondrian.olap.DriverManager; //导入依赖的package包/类
public void testSchema3noVersion() {
TestContext testContext =
TestContext.instance().withSchema(SCHEMA_3_HEADER + SCHEMA_3_BODY);
Util.PropertyList connectInfo =
testContext.getConnectionProperties();
Connection conn = DriverManager.getConnection(connectInfo, null);
assertNotNull(conn);
conn.close();
}
示例12: testSchema4withVersion
import mondrian.olap.DriverManager; //导入依赖的package包/类
public void testSchema4withVersion() {
TestContext testContext =
TestContext.instance().withSchema(SCHEMA_4_HEADER + SCHEMA_4_BODY);
Util.PropertyList connectInfo =
testContext.getConnectionProperties();
try {
Connection conn = DriverManager.getConnection(connectInfo, null);
conn.close();
Assert.fail("No exception thrown for version 4 schema.");
} catch (MondrianException e) {
assertTrue(e.getMessage().contains("Schema version"));
}
}
示例13: testSchema4noVersion
import mondrian.olap.DriverManager; //导入依赖的package包/类
public void testSchema4noVersion() {
TestContext testContext =
TestContext.instance().withSchema(
SCHEMA_4_NVHEADER + SCHEMA_4_BODY);
Util.PropertyList connectInfo =
testContext.getConnectionProperties();
try {
Connection conn = DriverManager.getConnection(connectInfo, null);
conn.close();
Assert.fail("No exception thrown for version 4 schema.");
} catch (MondrianException e) {
assertTrue(e.getMessage().contains("Schema version"));
}
}
示例14: openQuery
import mondrian.olap.DriverManager; //导入依赖的package包/类
public void openQuery() throws KettleDatabaseException {
connection = null;
if (databaseMeta.getAccessType() == DatabaseMeta.TYPE_ACCESS_JNDI){
DataSource dataSource = DataSourceProviderFactory.getDataSourceProviderInterface().getNamedDataSource(databaseMeta.getDatabaseName());
mondrian.olap.Util.PropertyList propList = new mondrian.olap.Util.PropertyList();
propList.put("Provider", "mondrian");
propList.put("Catalog", space.environmentSubstitute(catalog));
connection = DriverManager.getConnection(propList, null, dataSource);
}
else{
String connectString = "Provider=mondrian;" +
"Jdbc='"+space.environmentSubstitute(databaseMeta.getURL())+"';"+
"Catalog='"+space.environmentSubstitute(catalog)+"';"+
"JdbcDrivers="+space.environmentSubstitute(databaseMeta.getDriverClass())+";";
if (!Const.isEmpty(databaseMeta.getUsername())) {
connectString+="JdbcUser="+space.environmentSubstitute(databaseMeta.getUsername())+";";
}
if (!Const.isEmpty(databaseMeta.getPassword())) {
connectString+="JdbcPassword="+space.environmentSubstitute(databaseMeta.getPassword())+";";
}
connection = DriverManager.getConnection(connectString, null);
}
query = connection.parseQuery(queryString);
result = connection.execute(query);
}
示例15: valueBound
import mondrian.olap.DriverManager; //导入依赖的package包/类
/**
* create a new connection to Mondrian
*/
public void valueBound(HttpSessionBindingEvent ev) {
String connectString =
servletContext.getInitParameter("connectString");
LOGGER.debug("connectString: " + connectString);
this.connection =
DriverManager.getConnection(
connectString,
new ServletContextCatalogLocator(servletContext));
if (this.connection == null) {
throw new RuntimeException(
"No ROLAP connection from connectString: "
+ connectString);
}
}