Package org.apache.jorphan.collections

Examples of org.apache.jorphan.collections.Data


   * @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


        return model.getColumnAsObjectArray(colName);
    }

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

     */
    public void modifyTestElement(TestElement el) {
        if (table.isEditing()) {
            table.getCellEditor().stopCellEditing();
        }
        Data model = tableModel.getData();
        model.reset();
        while (model.next()) {
            el.setProperty(new StringProperty((String) model.getColumnValue(COLUMN_NAMES_0), (String) model
                    .getColumnValue(COLUMN_NAMES_1)));
        }
        super.configureTestElement(el);
    }
View Full Code Here

        return model.getColumnAsObjectArray(colName);
    }

    public void clearData() {
        String[] headers = model.getHeaders();
        model = new Data();
        model.setHeaders(headers);
        this.fireTableDataChanged();
    }
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(getName());
        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);
            res.setResponseData(data.toString().getBytes());
            res.setDataType(SampleResult.TEXT);
            res.setSuccessful(true);
        }
        catch (Exception ex)
        {
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

     *
     * @param el the TestElement to modify
     */
    public void modifyTestElement(TestElement el)
    {
        Data model = tableModel.getData();
        model.reset();
        while (model.next())
        {
            el.setProperty(
                new StringProperty(
                    (String) model.getColumnValue(COLUMN_NAMES[0]),
                    (String) model.getColumnValue(COLUMN_NAMES[1])));
        }
        super.configureTestElement(el);
    }
View Full Code Here

    }

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

     */
    public void modifyTestElement(TestElement el) {
        if (table.isEditing()) {
            table.getCellEditor().stopCellEditing();
        }
        Data model = tableModel.getData();
        model.reset();
        while (model.next()) {
            el.setProperty(new StringProperty((String) model.getColumnValue(COLUMN_NAMES_0), (String) model
                    .getColumnValue(COLUMN_NAMES_1)));
        }
        super.configureTestElement(el);
    }
View Full Code Here

        return model.getColumnAsObjectArray(colName);
    }

    public void clearData() {
        String[] headers = model.getHeaders();
        model = new Data();
        model.setHeaders(headers);
        this.fireTableDataChanged();
    }
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.