本文整理汇总了Java中mondrian.olap.DriverManager.getConnection方法的典型用法代码示例。如果您正苦于以下问题:Java DriverManager.getConnection方法的具体用法?Java DriverManager.getConnection怎么用?Java DriverManager.getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mondrian.olap.DriverManager
的用法示例。
在下文中一共展示了DriverManager.getConnection方法的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: 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);
}
示例4: 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;
}
示例5: 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);
}
}
示例6: 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();
}
示例7: 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();
}
示例8: 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"));
}
}
示例9: 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"));
}
}
示例10: 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);
}
示例11: 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);
}
}
示例12: Test
import mondrian.olap.DriverManager; //导入方法依赖的package包/类
Test(String[] args)
{
pw = new PrintWriter(System.out, true);
String connectString =
"Data Source=LOCALHOST;Provider=msolap;Catalog=Foodmart";
connection =
(RolapConnection) DriverManager.getConnection(connectString, null);
}
示例13: 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.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);
}
// clear cache before connecting
AggregationManager.instance().getCacheControl(null)
.flushSchemaCache();
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);
}
}
示例14: getFoodMartConnection
import mondrian.olap.DriverManager; //导入方法依赖的package包/类
/**
* Returns a connection to the FoodMart database.
*/
public synchronized Connection getFoodMartConnection() {
if (foodMartConnection == null) {
foodMartConnection =
DriverManager.getConnection(
getFoodMartConnectionProperties(),
null);
}
return foodMartConnection;
}
示例15: getMondrianConnection
import mondrian.olap.DriverManager; //导入方法依赖的package包/类
public mondrian.olap.Connection getMondrianConnection() throws Exception {
if (mondrianConnection == null)
{
JDBCConnection con = getJDBCConnection();
// Force opening connection...
ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
try {
Connection conn = null;
try {
conn = con.getConnection();
if (conn == null) throw new Exception("No DB connection");
} finally {
// Clean up
if( conn!=null ) try{ conn.close(); } catch(Exception e) { /* anyone really care? */ }
}
Thread.currentThread().setContextClassLoader( IReportManager.getReportClassLoader());
Util.PropertyList props = new Util.PropertyList();
props.put("Catalog", getCatalogUri());
props.put("Provider", "mondrian");
props.put("Locale", Locale.getDefault().getLanguage());
SimpleSQLDataSource ds = new SimpleSQLDataSource(con);
mondrianConnection = DriverManager.getConnection(props, null, ds);
/*
mondrianConnection = DriverManager.getConnection(
"Provider=mondrian;" +
"JdbcDrivers=" + escapeProperty( con.getJDBCDriver() ) + ";" +
"Jdbc=" + escapeProperty( con.getUrl() ) + ";" +
"JdbcUser=" + escapeProperty( con.getUsername() ) + ";" +
"JdbcPassword=" + escapeProperty( con.getPassword() ) + ";" +
"Catalog=" + escapeProperty( getCatalogUri() ) + ";",
null, false);
*/
} catch (Exception ex) {
ex.printStackTrace();
throw ex;
}
Thread.currentThread().setContextClassLoader( originalCL);
}
usedby++;
return mondrianConnection;
}