[jdom-interest] Re: ResultSetBuilder class giving xml document in reverse order

David Kavanagh dak at dotech.com
Thu Dec 5 07:12:26 PST 2002

I also noticed the lack of a "ORDER BY" in the SQL statement. Doesn't 
answer the original question, but I think by specifying order in the 
sql, one could be sure of the result order (and accommodate for the 
behavior of RStoXMLBuilder. Anyone have an aswer to why the document 
order isn't matching the result set order?


On 12/5/2002 8:55 AM, Robert (Jamie) Munro wrote:

>Your SQL can return rows in any order it wants unless you specify an ORDER
>BY clause.
>Robert Munro
>----- Original Message -----
>From: "Jasmin Mehta" <jmehta at mdnotes.com>
>To: "Jason Hunter" <jhunter at servlets.com>
>Sent: Thursday, December 05, 2002 1:06 AM
>Subject: ResultSetBuilder class giving xml document in reverse order
>Hi Jason,
>I'm getting the resultant XML document in reverse order of the rows I'm
>getting in my result set. How can I get the correct order?
>I've piece of code like below:
>StringBuffer sql = new StringBuffer();
>       sql.append("SELECT * FROM PatientData WHERE (Doc_Code =
>       for (int k = 0; k < doccode.length-1; k++)
>         sql.append(" OR (Doc_Code = '"+doccode[k+1]+"')");
>       String sql_1 = sql.toString();
>       String root = "PatientData";
>       String row  =  "PatientInfo";
>       rstoxml = new RStoXMLBuilder(conn, sql_1, root, row);
>       xmldoc  = rstoxml.getJDomObj();
>where RStoXMLBuilder class has below method
>public Document getJDomObj() {
>      Document doc = null;
>       rs = stmt.executeQuery(sql);
>       ResultSetBuilder builder = new ResultSetBuilder(rs);
>       builder.setRootName(root);
>       builder.setRowName(row);
>       doc = builder.build();
>       FileOutputStream out = new
>       XMLOutputter outputter = new XMLOutputter();
>       outputter.output(doc, out);
>    return doc;
>Here, I can see that SOAP.xml is displaying <patientInfo> nodes in
>descending order of what I'm getting rows as a resultset.
>-----Original Message-----
>From: Jason Hunter [mailto:jhunter at servlets.com]
>Sent: Thursday, November 21, 2002 6:46 PM
>To: Jasmin Mehta
>Subject: Re: ResultSetBuilderDemo.java
>The latest code change was minor.  The code will very likely work.  Give
>it a shot.
>To control your jdom-interest membership:

More information about the jdom-interest mailing list