Package org.pentaho.commons.connection

Examples of org.pentaho.commons.connection.IPentahoResultSet


      if ( ComponentBase.debug ) {
        debug( Messages.getInstance().getString( "MDXBaseComponent.DEBUG_RUNNING_QUERY", query ) ); //$NON-NLS-1$
      }

      // evaluate
      IPentahoResultSet resultSet = connection.executeQuery( query );
      rSet = resultSet;
      return resultSet;
    } catch ( Exception e ) {
      error( Messages.getInstance().getErrorString( "MDXBaseComponent.ERROR_0006_EXECUTE_FAILED", getActionName() ), e ); //$NON-NLS-1$
    }
View Full Code Here


      if ( ComponentBase.debug ) {
        debug( Messages.getInstance().getString( "MDXBaseComponent.DEBUG_RUNNING_QUERY", rawQuery ) ); //$NON-NLS-1$
      }

      // execute the query, read the results and cache them
      IPentahoResultSet resultSet = localConnection.executeQuery( rawQuery );
      if ( resultSet != null && resultSet instanceof MDXResultSet ) {
        // BISERVER-3543 - set the result set to return formatted cell values
        boolean formattedCellValues = false;
        if ( isDefinedInput( FORMATTED_CELL_VALUES ) ) {
          formattedCellValues = getInputBooleanValue( FORMATTED_CELL_VALUES, false );
View Full Code Here

      if ( ComponentBase.debug ) {
        dumpQuery( query );
      }

      // evaluate
      IPentahoResultSet resultSet = null;
      if ( preparedParameters.size() > 0 ) {
        resultSet = connection.prepareAndExecuteQuery( query, copyOfPreparedParameters );
      } else {
        resultSet = connection.executeQuery( query );
      }

      if ( connection instanceof SQLConnection ) {
        if ( ( (SQLConnection) connection ).isForcedForwardOnly() ) {
          warn( Messages.getInstance().getString( "SQLBaseComponent.WARN_FALL_BACK_TO_NONSCROLLABLE" ) ); //$NON-NLS-1$
        }
      }

      boolean live = true;
      IActionDefinition actionDefinition = getActionDefinition();
      if ( actionDefinition instanceof AbstractRelationalDbAction ) {
        AbstractRelationalDbAction relationalDbAction = (AbstractRelationalDbAction) actionDefinition;
        live = relationalDbAction.getLive().getBooleanValue( false );
      }

      IPentahoResultSet rs = resultSet;

      // BISERVER-5915, BISERVER-5875 - if the live setting is false, return an in memory resultset.
      if ( !live ) {
        rs = resultSet.memoryCopy();
      }
View Full Code Here

        }
      }

      AbstractRelationalDbAction relationalDbAction = (AbstractRelationalDbAction) getActionDefinition();

      IPentahoResultSet resultSet = null;
      boolean isForwardOnly = relationalDbAction.getUseForwardOnlyResultSet().getBooleanValue( false );

      resultSet = doQuery( sqlConnection, query, isForwardOnly );

      if ( sqlConnection.isForcedForwardOnly() ) {
        isForwardOnly = true;
        live = false;
        warn( Messages.getInstance().getString( "SQLBaseComponent.WARN_FALL_BACK_TO_NONSCROLLABLE" ) ); //$NON-NLS-1$
      }

      if ( live ) {

        // set the result set as the output
        rSet = resultSet;

        // After preparation and execution, we need to clear out the
        // prepared parameters.
        preparedParameters.clear();
        if ( resultSet != null ) {
          getMetadata( resultSet, true );
          IActionOutput actionOutput = relationalDbAction.getOutputResultSet();
          if ( actionOutput != null ) {
            actionOutput.setValue( resultSet );
          }
          return true;
        } else {
          // close the connection if owner
          error( Messages.getInstance().getErrorString( "SQLBaseComponent.ERROR_0006_EXECUTE_FAILED",
            getActionName() ) ); //$NON-NLS-1$
          if ( connectionOwner ) {
            connection.close();
          }
          return false;
        }

      } else {
        // execute the query, read the results and cache them
        try {
          // After preparation and execution, we need to clear out the
          // prepared parameters.
          preparedParameters.clear();

          IPentahoResultSet cachedResultSet = resultSet.memoryCopy();
          rSet = cachedResultSet;

          IActionOutput actionOutput = relationalDbAction.getOutputResultSet();
          if ( actionOutput != null ) {
            actionOutput.setValue( cachedResultSet );
View Full Code Here

    // It is possible that the sqlConnection will be null, but the connection
    // won't be if someone is using their own implementation of the SQLConnection from
    // the factory.
    //

    IPentahoResultSet resultSet = null;
    if ( ComponentBase.debug ) {
      dumpQuery( query );
    }

    if ( preparedParameters.size() > 0 ) {
View Full Code Here

            for ( Object element : pObj ) {
              preparedParameters.add( element );
              parameterBuffer.append( ( parameterBuffer.length() == 0 ) ? "?" : ",?" ); //$NON-NLS-1$ //$NON-NLS-2$
            }
          } else if ( parameterValue instanceof IPentahoResultSet ) {
            IPentahoResultSet rs = (IPentahoResultSet) parameterValue;
            // See if we can find a column in the metadata with the same
            // name as the input
            IPentahoMetaData md = rs.getMetaData();
            int columnIdx = -1;
            if ( md.getColumnCount() == 1 ) {
              columnIdx = 0;
            } else {
              columnIdx = md.getColumnIndex( new String[] { parameter } );
            }
            if ( columnIdx < 0 ) {
              error( Messages.getInstance().getErrorString( "Template.ERROR_0005_COULD_NOT_DETERMINE_COLUMN" ) ); //$NON-NLS-1$
              return -1;
            }
            int rowCount = rs.getRowCount();
            Object valueCell = null;
            // TODO support non-string columns
            for ( int i = 0; i < rowCount; i++ ) {
              valueCell = rs.getValueAt( i, columnIdx );
              preparedParameters.add( valueCell );
              parameterBuffer.append( ( parameterBuffer.length() == 0 ) ? "?" : ",?" ); //$NON-NLS-1$ //$NON-NLS-2$
            }
          } else if ( parameterValue instanceof List ) {
            List pObj = (List) parameterValue;
View Full Code Here

              for ( Object element : pObj ) {
                paramList.add( index++, element );
                parameterBuffer.append( ( parameterBuffer.length() == 0 ) ? "?" : ",?" ); //$NON-NLS-1$ //$NON-NLS-2$
              }
            } else if ( parameterValue instanceof IPentahoResultSet ) {
              IPentahoResultSet rs = (IPentahoResultSet) parameterValue;
              // See if we can find a column in the metadata with the same
              // name as the input
              IPentahoMetaData md = rs.getMetaData();
              int columnIdx = -1;
              if ( md.getColumnCount() == 1 ) {
                columnIdx = 0;
              } else {
                columnIdx = md.getColumnIndex( new String[] { parameter } );
              }
              if ( columnIdx < 0 ) {
                error( Messages.getInstance().getErrorString( "Template.ERROR_0005_COULD_NOT_DETERMINE_COLUMN" ) ); //$NON-NLS-1$
                return -1;
              }
              int rowCount = rs.getRowCount();
              Object valueCell = null;
              // TODO support non-string columns
              for ( int i = 0; i < rowCount; i++ ) {
                valueCell = rs.getValueAt( i, columnIdx );
                paramList.add( index++, valueCell );
                parameterBuffer.append( ( parameterBuffer.length() == 0 ) ? "?" : ",?" ); //$NON-NLS-1$ //$NON-NLS-2$
              }
            } else if ( parameterValue instanceof List ) {
              List pObj = (List) parameterValue;
View Full Code Here

   * iterate over and close all resultsets. Remove each result set from the list.
   */
  private void closeResultSets() {
    Iterator iter = resultSets.iterator();
    while ( iter.hasNext() ) {
      IPentahoResultSet rset = (IPentahoResultSet) iter.next();
      if ( rset != null ) {
        try {
          rset.close();
        } catch ( Exception ignored ) {
          //ignored
        }
      }
      iter.remove();
View Full Code Here

  @Override
  public Document getXmlContent() {

    // get the data to populate the widgets
    IPentahoResultSet resultSet = null;
    if ( solution != null ) {
      resultSet = getActionData();
    }

    // create the widget to use
View Full Code Here

            outputHandler, null, urlFactory, messages );

    if ( actionOutput != null ) {
      if ( context.getOutputNames().contains( actionOutput ) ) {
        IActionParameter output = context.getOutputParameter( actionOutput );
        IPentahoResultSet results = output.getValueAsResultSet();
        if ( results != null ) {
          results = results.memoryCopy();
        }
        return results;
      } else {
        // this is an error
        return null;
      }
    } else {
      // return the first list that we find...
      Iterator it = context.getOutputNames().iterator();
      while ( it.hasNext() ) {
        IActionParameter output = (IActionParameter) it.next();
        if ( output.getType().equalsIgnoreCase( IActionParameter.TYPE_RESULT_SET ) ) {
          IPentahoResultSet results = output.getValueAsResultSet();
          if ( results != null ) {
            results = results.memoryCopy();
          }
          return results;
        }
      }
    }
View Full Code Here

TOP

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

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.