|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.etools.sqltoxml.SQLToXML
This class provides methods used by applications (such as the SQL to XML wizard) to perform database queries. The query result is obtained in an XML format. Optionally, corresponding DTD, XML schema, and XSL files of the result can be generated.
Constructor Summary | |
SQLToXML(QueryProperties qProperties)
This is the only constructor. |
Method Summary | |
void |
execute()
Executes a query based on information from QueryProperties given as the constructor argument. |
void |
execute(java.io.PrintWriter xml,
java.lang.String dtdfile,
java.lang.String xsdfile,
java.io.PrintWriter xsl)
Deprecated. Executes a query based on information from QueryProperties and the results are written to the PrintWriters and/or files. When any argument other than 'xml' is null, no result is generated for that particular argument. Also, if both dtdfile and xsdfile are specified, only xsdfile is generated. |
void |
execute(java.lang.String params,
java.io.PrintWriter xml,
java.lang.String dtdfile,
java.lang.String xsdfile,
java.io.PrintWriter xsl)
Deprecated. Executes a query based on information from QueryProperties and the results are written to the PrintWriters and/or files. When any argument other than 'xml' is null, no result is generated for that particular argument. Also, if both dtdfile and xsdfile are specified, only xsdfile is generated. This method is used when the query contains a where-clause and its constraints are given in 'params' String argument. These constraint parameters are delimited using comma (,) in the argument. |
void |
execute(java.lang.String xmlfile,
java.lang.String dtdfile,
java.lang.String xsdfile,
java.lang.String xslfile)
Deprecated. Executes a query based on information from QueryProperties and the results are written to the files. When any argument other than 'xml' is null, no result is generated for that particular argument. Also, if both dtdfile and xsdfile are specified, only xsdfile is generated. |
void |
finalize()
Closes the connection if it was created by SQLToXML. |
java.sql.Connection |
getConnection()
Returns a database connection. |
org.w3c.dom.Document |
getCurrentDocument()
Returns the XML document that is a result of the most recent call to the execute() method. |
org.w3c.dom.Document[] |
getCurrentDocuments()
Returns the XML documents array that is a result of the most recent call to the execute() method. |
java.lang.String |
getDTDFile()
Returns current DTD file name to be generated. |
java.lang.String |
getNextAllQuery()
Returns a valid query string. |
java.util.Vector |
getNextQueries()
Returns a sequence of valid query strings. |
java.lang.String |
getParameters()
Returns the parameter values for the where-clause. |
java.lang.String |
getXMLFile()
Returns current XML file name to be generated. |
java.io.PrintWriter |
getXMLWriter()
Returns current PrintWriter for the XML output. |
java.lang.String |
getXSDFile()
Returns current XML schema file name to be generated. |
java.lang.String |
getXSLFile()
Returns current XSL file name to be generated. |
java.io.PrintWriter |
getXSLWriter()
Returns current PrintWriter for the XSL output. |
void |
setConnection(java.sql.Connection jdbcConnection)
Provides a JDBC connection to be used for generating the XML files. |
void |
setDTDFile(java.lang.String filename)
Sets the DTD file name to be generated. |
void |
setGenDocType(boolean value)
Deprecated. Controls whether or not to generate a DTD or an XML schema file for validation purposes. |
void |
setIndenting(boolean flag)
Sets indentation on and off. |
void |
setMaxRows(int max)
Sets the limit for the maximum number of rows to be retrieved in the generated XML. |
void |
setParameters(java.lang.String parameters)
Sets the parameter values for the where-clause. |
void |
setQueryProperties(QueryProperties qProperties)
Overrides current QueryProperties. |
void |
setTargetNamespace(java.lang.String targetNamespace)
Sets the target namespace of the generated XML. |
void |
setXMLFile(java.lang.String filename)
Sets the XML file name to be generated. |
void |
setXMLWriter(java.io.PrintWriter writer)
Sets the PrintWriter to which the generated XML is directed. |
void |
setXSDFile(java.lang.String filename)
Sets the XML schema file name to be generated. |
void |
setXSLFile(java.lang.String filename)
Sets the XSL file name to be generated. |
void |
setXSLWriter(java.io.PrintWriter writer)
Sets the PrintWriter to which the generated XSL is directed. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SQLToXML(QueryProperties qProperties)
Method Detail |
public void execute() throws java.lang.Exception
Usage pattern:
QueryProperties properties = new QueryProperties();
... set the query property values ...
SQLToXML sqltoxml = new SQLToXML(properties);
... set necessary values for sqltoxml ...
sqltoxml.execute();
// Next line is if you want to retrieve the XML document
Document doc = sqltoxml.getCurrentDocument();
java.lang.Exception
- Thrown when the execution fails.QueryProperties
,
setXMLFile(java.lang.String)
,
setXMLWriter(java.io.PrintWriter)
,
setDTDFile(java.lang.String)
,
setXSDFile(java.lang.String)
,
setXSLFile(java.lang.String)
,
setXSLWriter(java.io.PrintWriter)
,
setParameters(java.lang.String)
public void setXMLFile(java.lang.String filename) throws java.lang.Exception
filename
- An XML file name to be generatedjava.lang.Exception
- Thrown if setXMLWriter(PrintWriter) or
setXSLWriter(PrintWriter) has been called already.setXMLWriter(java.io.PrintWriter)
public java.lang.String getXMLFile()
setXMLFile(java.lang.String)
public void setXMLWriter(java.io.PrintWriter writer) throws java.lang.Exception
filename
- A PrintWriter where the XML is going to be directed.java.lang.Exception
- Thrown if setXMLFile(PrintWriter) or
setXSLFile(PrintWriter) has been called already.setXMLFile(java.lang.String)
public java.io.PrintWriter getXMLWriter()
setXMLWriter(java.io.PrintWriter)
public void setXSDFile(java.lang.String filename) throws java.lang.Exception
filename
- An XML schema file name to be generatedjava.lang.Exception
- Thrown if setDTDFile(String)
has been called already.setDTDFile(java.lang.String)
public java.lang.String getXSDFile()
setXSDFile(java.lang.String)
public void setDTDFile(java.lang.String filename) throws java.lang.Exception
filename
- A DTD file name to be generatedjava.lang.Exception
- Thrown if setXSDFile(String)
has been called already.setDTDFile(java.lang.String)
public java.lang.String getDTDFile()
setDTDFile(java.lang.String)
public void setXSLFile(java.lang.String filename) throws java.lang.Exception
filename
- An XSL file name to be generatedjava.lang.Exception
- Thrown if setXSLWriter(PrintWriter) or
setXMLWriter(PrintWriter) has been called already.setXSLWriter(java.io.PrintWriter)
public java.lang.String getXSLFile()
setXSLFile(java.lang.String)
public void setXSLWriter(java.io.PrintWriter writer) throws java.lang.Exception
filename
- A PrintWriter where the XSL is going to be directed.java.lang.Exception
- Thrown if setXSLFile(PrintWriter) or
setXMLFile(PrintWriter) has been called already.setXSLFile(java.lang.String)
public java.io.PrintWriter getXSLWriter()
setXSLWriter(java.io.PrintWriter)
public void setParameters(java.lang.String parameters)
select * from EMPLOYEE where EMP_NO = :empnoFrom the above example, the value to be replaced for :empno is given in the parameters argument. If there are multiple constraint values, they are delimited using comma (,) in the parameters like in the following example.
String params = "87316,'Toronto'";
sqltoxml.setParameters(params);
parameters
- The where-clause parameter values when they existpublic java.lang.String getParameters()
setParameters(java.lang.String)
public void setMaxRows(int max)
max
- The limit for the number of rows. Zero means there is
no limit.public void setIndenting(boolean flag)
flag
- false if indentation should be off.public org.w3c.dom.Document[] getCurrentDocuments()
getCurrentDocument()
public org.w3c.dom.Document getCurrentDocument()
getCurrentDocuments()
public void setConnection(java.sql.Connection jdbcConnection)
jdbcConnection
- A JDBC connectionpublic java.sql.Connection getConnection() throws java.lang.Exception
java.lang.Exception
- Thrown when a connection is not available.public void finalize()
public void setGenDocType(boolean value)
value
- false for not generating a DTD or an XML
schema file, and true otherwise.public void setQueryProperties(QueryProperties qProperties)
public void execute(java.io.PrintWriter xml, java.lang.String dtdfile, java.lang.String xsdfile, java.io.PrintWriter xsl) throws java.lang.Exception
xml
- A PrintWriter for an XML result.dtdfile
- A DTD file name for the xml.xsdfile
- An XML schema file name for the xml.xsl
- A PrintWriter for a default XSL.java.lang.Exception
- Thrown when the execution fails.QueryProperties
public void execute(java.lang.String params, java.io.PrintWriter xml, java.lang.String dtdfile, java.lang.String xsdfile, java.io.PrintWriter xsl) throws java.lang.Exception
params
- where-clause constraint parameters delimited by comma(',').xml
- A PrintWriter for an XML result.dtdfile
- A DTD file name for the xml.xsdfile
- An XML schema file name for the xml.xsl
- A PrintWriter for a default XSL.java.lang.Exception
- Thrown when the execution fails.QueryProperties
public void execute(java.lang.String xmlfile, java.lang.String dtdfile, java.lang.String xsdfile, java.lang.String xslfile) throws java.lang.Exception
xmlfile
- An XML file name for the query result.dtdfile
- A DTD file name for the xmlfile.xsdfile
- An XML schema file name for the xmlfile.xslfile
- An XSL file name for a default XSL.java.lang.Exception
- Thrown when the execution fails.QueryProperties
public java.lang.String getNextAllQuery()
1) Format option is ID_AND_IDREF, and 2) Recurse option is 'TRUE'For example, when a column from the current query is a foreign key to a primary key column of table A, this will return a string 'select * from A'. Refer to the sample servlet XMLIntegratorServlet.java for a typical use of this method.
public java.util.Vector getNextQueries()
1) Format option is ID_AND_IDREF, and 2) Recurse option is 'TRUE'For example, when a column from the current query is a foreign key to a primary key column ID (with value 123) of table A, this will return a string 'select * from A where ID = 123'. Refer to the sample servlet XMLIntegratorServlet.java for a typical use of this method.
public void setTargetNamespace(java.lang.String targetNamespace)
targetNamespace
- The target namespace name of the output XML
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |