Package org.apache.jorphan.collections

Examples of org.apache.jorphan.collections.Data


    return model.getColumnAsObjectArray(colName);
  }

  public void clearData() {
    String[] headers = model.getHeaders();
    model = new Data();
    model.setHeaders(headers);
    this.fireTableDataChanged();
  }
View Full Code Here


      // Based on query return value, get results
      if (SELECT.equals(getQueryType())) {
        ResultSet rs = null;
        try {
          rs = stmt.executeQuery(getQuery());
          Data data = getDataFromResultSet(rs);
          res.setResponseData(data.toString().getBytes());
        } finally {
          if (rs != null) {
            try {
              rs.close();
            } catch (SQLException exc) {
View Full Code Here

   * @return a Data object
   * @throws java.sql.SQLException
   */
  private Data getDataFromResultSet(ResultSet rs) throws SQLException {
    ResultSetMetaData meta = rs.getMetaData();
    Data data = new Data();

    int numColumns = meta.getColumnCount();
    String[] dbCols = new String[numColumns];
    for (int i = 0; i < numColumns; i++) {
      dbCols[i] = meta.getColumnName(i + 1);
      data.addHeader(dbCols[i]);
    }

    while (rs.next()) {
      data.next();
      for (int i = 0; i < numColumns; i++) {
        Object o = rs.getObject(i + 1);
        if (o instanceof byte[]) {
          o = new String((byte[]) o);
        }
        data.addColumnValue(dbCols[i], o);
      }
    }
    return data;
  }
View Full Code Here

            {
                ResultSet rs = null;
                try
                {
                    rs = stmt.getResultSet();
                    Data data = getDataFromResultSet(rs);
                    res.setResponseData(data.toString().getBytes());
                }
                finally
                {
                    if (rs != null)
                    {
View Full Code Here

     * @throws    java.sql.SQLException
     */
    private Data getDataFromResultSet(ResultSet rs) throws SQLException
    {
        ResultSetMetaData meta = rs.getMetaData();
        Data data = new Data();

        int numColumns = meta.getColumnCount();
        String[] dbCols = new String[numColumns];
        for (int i = 0; i < numColumns; i++)
        {
            dbCols[i] = meta.getColumnName(i + 1);
            data.addHeader(dbCols[i]);
        }
       
        while (rs.next())
        {
            data.next();
            for (int i = 0; i < numColumns; i++)
            {
                Object o = rs.getObject(i + 1);
                if (o instanceof byte[])
                {
                    o = new String((byte[]) o);
                }
                data.addColumnValue(dbCols[i], o);
            }
        }
        return data;
    }
View Full Code Here

   *
   *@return   !ToDo (Return description)
   ***************************************/
  public TestElement createTestElement()
  {
    Data model = tableModel.getData();
    Arguments args = new Arguments();
    model.reset();
    while(model.next())
    {
      args.addArgument((String)model.getColumnValue(Arguments.COLUMN_NAMES[0]),
          model.getColumnValue(Arguments.COLUMN_NAMES[1]));
    }
    this.configureTestElement(args);
    return (TestElement)args.clone();
  }
View Full Code Here

    time = start = end = 0;
    SampleResult res = new SampleResult();
    Connection con = null;
    ResultSet rs = null;
    Statement stmt = null;
    Data data = new Data();
    res.setSampleLabel(getQuery());
    start = System.currentTimeMillis();
    try
    {
      int count = 0;
      while (count < 20 && (con = manager.getConnection(key)) == null)
      {
        try
        {
          Thread.sleep(10);
        }
        catch (Exception err)
        {
          count++;
        }
      }
      stmt = con.createStatement();
      // Execute database query
      boolean retVal = stmt.execute(getQuery());
      // Based on query return value, get results
      if (retVal)
      {
        rs = stmt.getResultSet();
        data = getDataFromResultSet(rs);
        rs.close();
      }
      else
      {
        int updateCount = stmt.getUpdateCount();
      }
      stmt.close();
      manager.releaseConnection(con);
    }
    catch (Exception ex)
    {
      if (rs != null)
      {
        try
        {
          rs.close();
        }
        catch (SQLException err)
        {
          rs = null;
        }
      }
      if (stmt != null)
      {
        try
        {
          stmt.close();
        }
        catch (SQLException err)
        {
          stmt = null;
        }
      }
      manager.releaseConnection(con);
      log.error("", ex);
    }
    // Calculate response time
    end = System.currentTimeMillis();
    time += end - start;
    res.setTime(time);
    res.setResponseData(data.toString().getBytes());
    res.setSamplerData(this);
    res.setSuccessful(true);
    return res;
  }
View Full Code Here

   *@throws  java.sql.SQLException
   ***********************************************************/
  private Data getDataFromResultSet(ResultSet rs) throws SQLException
  {
    ResultSetMetaData meta;
    Data data = new Data();
    meta = rs.getMetaData();
    int numColumns = meta.getColumnCount();
    String[] dbCols = new String[numColumns];
    for (int count = 1; count <= numColumns; count++)
    {
      dbCols[count - 1] = meta.getColumnName(count);
      data.addHeader(dbCols[count - 1]);
    }
    while (rs.next())
    {
      data.next();
      for (int count = 0; count < numColumns; count++)
      {
        Object o = rs.getObject(count + 1);
        if (o == null)
        {
        }
        else if (o instanceof byte[])
        {
          o = new String((byte[]) o);
        }
        data.addColumnValue(dbCols[count], o);
      }
    }
    return data;
  }
View Full Code Here

TOP

Related Classes of org.apache.jorphan.collections.Data

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.