Package org.pentaho.commons.connection

Examples of org.pentaho.commons.connection.IPentahoConnection


    return reportSpecEntry;
  }

  public IPentahoResultSet getResultSet( final ReportSpec reportSpec ) throws Exception {
    String jndiName = reportSpec.getReportSpecChoice().getJndiSource();
    IPentahoConnection connection = null;
    if ( reportSpec.getIsMDX() ) {
      // did this ever work??
      String connectStr = ""; //$NON-NLS-1$
      IDBDatasourceService datasourceService = PentahoSystem.getObjectFactory().get( IDBDatasourceService.class, null );
      String dsName = datasourceService.getDSBoundName( jndiName );
      if ( dsName != null ) {
        connectStr = "dataSource=" + dsName + "; Catalog=mondrian"; //$NON-NLS-1$ //$NON-NLS-2$
      } else {
        error( Messages.getInstance().getErrorString( "MDXBaseComponent.ERROR_0005_INVALID_CONNECTION" ) ); //$NON-NLS-1$
        return null;
      }
      Properties props = new Properties();
      props.setProperty( IPentahoConnection.CONNECTION, connectStr );
      props.setProperty( IPentahoConnection.PROVIDER, reportSpec.getMondrianCubeDefinitionPath() );

      connection =
          PentahoConnectionFactory.getConnection( IPentahoConnection.MDX_DATASOURCE, props, getSession(), this );
    } else {
      connection =
          PentahoConnectionFactory.getConnection( IPentahoConnection.SQL_DATASOURCE, jndiName, getSession(), this );
    }
    String query = ReportParameterUtility.setupParametersForActionSequence( reportSpec.getQuery() );
    query = setupQueryParameters( query );
    IPentahoResultSet res = connection.executeQuery( query );
    return res;
  }
View Full Code Here


    /*
     * TODO - This is where the "connection factory" action occurs. Based on if the datasourceType, location,
     * username, or password have changed then we create a new one.
     */
    String key = CONNECTION_PREFIX + datasourceType;
    IPentahoConnection connection = null;
    try {
      connection = PentahoSystem.getObjectFactory().get( IPentahoConnection.class, key, session );
      if ( connection instanceof IPentahoLoggingConnection ) {
        ( (IPentahoLoggingConnection) connection ).setLogger( logger );
      }
      connection.setProperties( properties );
    } catch ( ObjectFactoryException e ) {
      Logger.error( PentahoSystem.class.getName(), Messages.getInstance().getErrorString(
          "PentahoConnectionFactory.ERROR_0001_COULD_NOT_CREATE_CONNECTION", key ), e ); //$NON-NLS-1$
    }

View Full Code Here

        // instead of creating our own.
        if ( queryAction.getMdxConnection() != ActionInputConstant.NULL_INPUT ) {
          if ( queryAction.getMdxConnection().getValue() != null ) {
            connectionOwner = false;
            IPreparedComponent component = (IPreparedComponent) queryAction.getMdxConnection().getValue();
            IPentahoConnection conn = component.shareConnection();
            if ( conn.getDatasourceType() == IPentahoConnection.MDX_DATASOURCE ) {
              connection = conn;
            } else {
              error( Messages.getInstance().getErrorString(
                  "IPreparedComponent.ERROR_0001_INVALID_CONNECTION_TYPE", getActionName() ) ); //$NON-NLS-1$           
            }
View Full Code Here

   * attempt to aquire a connection. if connection isn't available, wait a certain period of time before trying again.
   *
   * @return connection
   */
  public IPentahoConnection getDatasourceConnection() {
    IPentahoConnection con;
    int[] timeouts = { 200, 500, 2000 };
    for ( int element : timeouts ) {
      try {
        con = getConnection();
        try {
          con.clearWarnings();
        } catch ( Exception ex ) {
          //ignored
        }
        return con;
      } catch ( Exception ex ) {
        //ignored
      }
      waitFor( element );
    }
    con = getConnection();
    try {
      con.clearWarnings();
    } catch ( Exception ex ) {
      //ignore
    }
    return con;
  }
View Full Code Here

    return mdxConnection;
  }

  protected IPentahoConnection getConnectionOrig() {
    IPentahoConnection localConnection = null;
    MdxConnectionAction connAction = (MdxConnectionAction) getActionDefinition();
    try {
      String mdxConnectionStr = connAction.getMdxConnectionString().getStringValue();
      Properties mdxConnectionProps = (Properties) connAction.getConnectionProps().getValue();
      String jdbcStr = connAction.getConnection().getStringValue();
View Full Code Here

          this.setReadOnly( readOnlyInput.getBooleanValue() );
        }

        if ( sharedConnection != null ) {
          connectionOwner = false;
          IPentahoConnection conn = sharedConnection.shareConnection();
          if ( conn == null ) {
            error( Messages.getInstance().getErrorString(
                "IPreparedComponent.ERROR_0002_CONNECTION_NOT_AVAILABLE", getActionName() ) ); //$NON-NLS-1$
            return false;
          } else if ( conn.getDatasourceType() == IPentahoConnection.SQL_DATASOURCE ) {
            connection = conn;
          } else {
            error( Messages.getInstance().getErrorString(
                "IPreparedComponent.ERROR_0001_INVALID_CONNECTION_TYPE", getActionName() ) ); //$NON-NLS-1$
            return false;
View Full Code Here

   * attempt to aquire a connection. if connection isn't available, wait a certain period of time before trying again.
   *
   * @return connection
   */
  public IPentahoConnection getDatasourceConnection() {
    IPentahoConnection con;
    int[] timeouts = { 200, 500, 2000 };
    for ( int element : timeouts ) {
      try {
        con = getConnection();
        try {
          con.clearWarnings();
        } catch ( Exception ex ) {
          //ignore
        }
        return con;
      } catch ( Exception ex ) {
        //ignore
      }
      waitFor( element );
    }
    con = getConnection();
    try {
      con.clearWarnings();
    } catch ( Exception ex ) {
      //ignore
    }
    return con;
  }
View Full Code Here

   * @param defaultConnection
   *          a default connection to use if no other is available
   * @return new connection object
   */
  protected IPentahoConnection getConnection( final IPentahoConnection defaultConnection ) {
    IPentahoConnection localConnection = null;
    try {
      String jndiName = null;
      String driver = null;
      String userId = null;
      String password = null;
View Full Code Here

        String query = queryAction.getQuery().getStringValue();

        if ( queryAction.getInputSharedConnection() != ActionInputConstant.NULL_INPUT ) {
          connectionOwner = false;
          IPreparedComponent component = (IPreparedComponent) queryAction.getInputSharedConnection().getValue();
          IPentahoConnection conn = component.shareConnection();
          if ( IPentahoConnection.HQL_DATASOURCE.equals( conn.getDatasourceType() ) ) {
            connection = conn;
          } else {
            connection = null;
            returnValue = false;
            error( Messages.getInstance().getErrorString(
View Full Code Here

    }
    connection = null;
  }

  protected IPentahoConnection getConnection( final File hbmCfgFile, final String[] classNames ) {
    IPentahoConnection conn = null;
    try {
      conn = (HQLConnection) PentahoConnectionFactory.getConnection( "HQL", getSession(), this ); //$NON-NLS-1$
      HQLConnection hconn = (HQLConnection) conn;
      hconn.setConfigFile( hbmCfgFile );
      hconn.setClassNames( classNames );
View Full Code Here

TOP

Related Classes of org.pentaho.commons.connection.IPentahoConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.