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


Java DriverManager.getConnection方法代码示例

本文整理汇总了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;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:23,代码来源:MondrianApp.java

示例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);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:19,代码来源:MondrianDataAdapterService.java

示例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);
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:18,代码来源:MondrianHelper.java

示例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;
}
 
开发者ID:OSBI,项目名称:mondrian,代码行数:17,代码来源:CmdRunner.java

示例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);
    }
}
 
开发者ID:OSBI,项目名称:mondrian,代码行数:35,代码来源:Workbench.java

示例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();
}
 
开发者ID:OSBI,项目名称:mondrian,代码行数:10,代码来源:SchemaVersionTest.java

示例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();
}
 
开发者ID:OSBI,项目名称:mondrian,代码行数:10,代码来源:SchemaVersionTest.java

示例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"));
    }
}
 
开发者ID:OSBI,项目名称:mondrian,代码行数:14,代码来源:SchemaVersionTest.java

示例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"));
    }
}
 
开发者ID:OSBI,项目名称:mondrian,代码行数:15,代码来源:SchemaVersionTest.java

示例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);
    }
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:32,代码来源:MondrianHelper.java

示例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);
    }
}
 
开发者ID:Twixer,项目名称:mondrian-3.1.5,代码行数:18,代码来源:ResultCache.java

示例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);
}
 
开发者ID:Twixer,项目名称:mondrian-3.1.5,代码行数:9,代码来源:Test.java

示例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);
    }
}
 
开发者ID:Twixer,项目名称:mondrian-3.1.5,代码行数:39,代码来源:Workbench.java

示例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;
}
 
开发者ID:Twixer,项目名称:mondrian-3.1.5,代码行数:13,代码来源:TestContext.java

示例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;
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:54,代码来源:MondrianConnection.java


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