jcs.xml.resultset
Class RX

java.lang.Object
  |
  +--jcs.xml.resultset.RX

public class RX
extends java.lang.Object
implements java.io.Serializable

A class whose static method sql2Xml converts the SQL result set yielded by a given SQL query into an XML <ResultSet> document.

See Also:
Serialized Form

Method Summary
static java.lang.String sql2Xml(java.lang.String query, java.lang.String cdataColumns, java.lang.String columnNameOption, java.lang.String server)
          Returns an XML representation of the SQL result set returned by the argument query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sql2Xml

public static java.lang.String sql2Xml(java.lang.String query,
                                       java.lang.String cdataColumns,
                                       java.lang.String columnNameOption,
                                       java.lang.String server)
                                throws java.lang.ClassNotFoundException,
                                       java.sql.SQLException,
                                       java.lang.Exception
Returns an XML representation of the SQL result set returned by the argument query.

This method is the body of the ResultSetXml constructor. It is placed in a separate class to make it easier to examine and maintain. It can also be useful as a standalone routine.

Example Java code:

 
  String  rsx 
     = RX.sql2Xml("select d.name, e.name, d.dno "
            +"from emps e, dept d "
            + " where e.dno = d.dno order by d.name, e.name",
           "000", "yes", "antibes:4000?user=sa"); 
  

This call evaluates the given query and returns a String containing an XML representation of the result set.

Comparison of this method RX.sql2Xml and the constructor for ResultSetXml.

The cdataColumns parameter is a string whose i-th character is 0 or 1 indicating whether (or not) the i-th column should be a CDATA section. For example, the following value of the cdataColumns parameter would indicate that columns 2, 5, and 7 should be CDATA sections, and columns 1, 3, 4, 6, 8, and 9 are normal text:

      "010010100"
  

The columnNameOption parameter indicates whether the output XML document should include column name attributes in the individual column tags. The column names are not needed or used by the XS.resultSet2Script method. The column names increase the size of the output XML document, but improve its readability and may be useful for some applications.

Parameters:
query - a string that is the SQL query whose result set is to be returned as an XML document
cdataColumns - a string indicating which columns of the result set should be specified as CDATA sections in the output XML document. See above.
columnNameOption - a string indicating whether (yes) or not (no) the <Column> tags in the output XML document should have column name attributes. See above.
server - a string that identifies the SQL server in which to execute the query. See the connectTo method for a description of this parameter.
Returns:
a string with the output XML document that contains the XML representation of the result set
Throws:
java.lang.ClassNotFoundException - Thrown when the XML parser class cannot be loaded.
java.sql.SQLException - Thrown for any exceptions raised during execution of the SQL statement
java.lang.Exception - Thrown for invalid parameters and other conditions