Java Code Examples for mondrian.olap.DriverManager#getConnection()

The following examples show how to use mondrian.olap.DriverManager#getConnection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MondrianApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: MondrianDataAdapterService.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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);
	}
}
 
Example 3
Source File: DataSourceService.java    From youkefu with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param cube
 * @throws Exception
 */
public Connection service(String xml) throws Exception {
	Connection dataSourceObject = null ;
	StringBuffer strb = new StringBuffer();
	Util.PropertyList properties = Util.parseConnectString(strb.append("Provider=mondrian;")
				.append(
			       "Catalog=").append(xml).append(";").toString());
	if(properties!=null){
		dataSourceObject = DriverManager.getConnection(properties,null , dataSource) ;
	}
	return dataSourceObject ;
}
 
Example 4
Source File: DefaultMondrianConnectionProvider.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Connection createConnection( final Properties properties, final DataSource dataSource )
  throws ReportDataFactoryException {
  logger.debug( "Creating Mondrian connection: " + Util.parseConnectString( computeConnectionString( properties ) ) );
  return DriverManager
    .getConnection( Util.parseConnectString( computeConnectionString( properties ) ), null, dataSource );
}
 
Example 5
Source File: MondrianHelper.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings( "deprecation" )
public void openQuery() throws KettleDatabaseException {

  connection = null;
  String realRole = space.environmentSubstitute( role );

  if ( databaseMeta.getAccessType() == DatabaseMeta.TYPE_ACCESS_JNDI ) {
    DataSource dataSource = ( new DatabaseUtil() ).getNamedDataSource( databaseMeta.getDatabaseName() );
    mondrian.olap.Util.PropertyList propList = new mondrian.olap.Util.PropertyList();
    propList.put( "Provider", "mondrian" );
    propList.put( "Catalog", space.environmentSubstitute( catalog ) );

    if ( !Utils.isEmpty( realRole ) ) {
      propList.put( "Role", realRole );
    }

    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 ( !Utils.isEmpty( databaseMeta.getUsername() ) ) {
      connectString += "JdbcUser=" + space.environmentSubstitute( databaseMeta.getUsername() ) + ";";
    }
    String password = databaseMeta.getPassword();
    if ( !Utils.isEmpty( password ) ) {
      String realPassword = Utils.resolvePassword( space, password );
      connectString += "JdbcPassword=" + space.environmentSubstitute( realPassword ) + ";";
    }

    if ( !Utils.isEmpty( realRole ) ) {
      connectString += "Role=" + realRole + ";";
    }

    connection = DriverManager.getConnection( connectString, null );

  }

  query = connection.parseQuery( queryString );
  result = connection.execute( query );
}