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

Robert (Jamie) Munro rjmunro at arjam.net
Thu Dec 5 05:55:35 PST 2002


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 =
'"+doccode[0]+"')");
       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
FileOutputStream("C:/JRun4/servers/default/MDNotes/secretary/SOAP.xml");
       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.

Thanks
Jasmin
-----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.

-jh-






More information about the jdom-interest mailing list