cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anders Heintz <hei...@include-datorkonsulter.se>
Subject Re: Problems with Cocoon 1.7 sql processing
Date Mon, 06 Mar 2000 21:32:39 GMT
Hello again...

> When I am trying to extract data from the database,
> VARCHAR and INT fields are correct, but TEXT and BLOB
> fields are not. Seems like the values returned are
> references, they are definitely not strings.

Solved this by changing from a ResultSet.getObject() call
to a  ResultSet.getString() in SQLProcessor.processQuery.
I would appreciate comments, will anything malfunction due
to this change?

I'm enclosing the modified code section with my change
marked (line 271 in SQLProcessor.java).

Regards

......./Anders Heintz



/* ********** LINE: 260 END OF CODE SECTION ************* */

ColumnFormatter formatter = new ColumnFormatter(query_element);
while (rs.next()) {
  if (create_row_elements) {
    row_element = Utils.createElement(document,namespace,
                                      row_element_name);
    row_node = row_element;
    if (create_id_attribute && id_attribute_column_index == -1) {
      row_element.setAttribute(id_attribute,"" + count);
    }
  }

  for (int i=0; i<columns.length; i++) {

/* **************** START OF CHANGES ****************** */

    Object value = rs.getString(i+1);

/* ***************** END OF CHANGES ******************* */

    if (create_row_elements && create_id_attribute
        && id_attribute_column_index == i) {
      row_element.setAttribute(id_attribute, value.toString());
      continue;
    }
    if (value == null && null_mode == OMIT_NULLS) continue;
    column_element = Utils.createElement(document,namespace,
                                         columns[i].name);
    if (value == null && null_mode == ATTRIBUTE_NULLS) {
      column_element.setAttribute("NULL","YES");
      column_element.appendChild(document.createTextNode(""));
    } else {
   formatter.addColumnNode(document,column_element,
                              columns[i],value,i+1);
    }
    row_node.appendChild(column_element);
  }
  if (create_row_elements) results_node.appendChild(row_node);
  if (count-skip_rows == max_rows-1) break;
  count++;
}
rs.close();

/* ********** LINE: 291 END OF CODE SECTION ************* */

Mime
View raw message