|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectpt.moredata.xml.db.DbToXML
DbToXML is a class that provides a static method to convert an SQL statement in a string to a XML Element in JDOM fashion. It also should work with our DAOs and Java's ResultSets.
Here is an example of how it can be used:
public static void main( String[] args ) {
try {
// Obtain a conection to a DB
Connection dbCon = getConnection2DB();
// Obtain the XML Element with the database data and put it in a Document
Document myDoc = new Document(JDOMconverter("SELECT * FROM esisit ORDER BY asitdes",
dbCon, "esisit", "row"));
// Format the Document and show it
XMLOutputter outputter = new XMLOutputter(" ", true);
outputter.setEncoding("ISO-8859-1");
outputter.output(myDoc, System.out);
} catch (Exception e) {
System.out.println("Error: "+e.getMessage());
}
}
| Constructor Summary | |
DbToXML()
Creates a new instance of DbToXML - no need for this - do not use |
|
| Method Summary | |
static org.jdom.Element |
JDOMconverter(DataAccessObject dao,
java.lang.String elementName,
java.lang.String rowDesignator)
Returns a JDOM Element containing the contents of the DAO |
static org.jdom.Element |
JDOMconverter(java.sql.ResultSet rs,
java.lang.String elementName,
java.lang.String rowDesignator)
Returns a JDOM Element containing the contents of the ResultSet, assuming that it has already executed the query |
static org.jdom.Element |
JDOMconverter(java.lang.String SQLCommand,
java.sql.Connection DBConn,
java.lang.String elementName,
java.lang.String rowDesignator)
Returns a JDOM Element containing the result of the query that is passed as a string |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public DbToXML()
| Method Detail |
public static org.jdom.Element JDOMconverter(java.lang.String SQLCommand,
java.sql.Connection DBConn,
java.lang.String elementName,
java.lang.String rowDesignator)
throws java.sql.SQLException
SQLCommand - The query in SQLDBConn - The connection to the databaseelementName - The name of the Element in the XML structurerowDesignator - The name of the row Elements in the XML structure
java.sql.SQLException - Yes it does. :-)
public static org.jdom.Element JDOMconverter(DataAccessObject dao,
java.lang.String elementName,
java.lang.String rowDesignator)
throws java.sql.SQLException
dao - The DAO to be convertedelementName - see aboverowDesignator - see above
java.sql.SQLException - Yup!
public static org.jdom.Element JDOMconverter(java.sql.ResultSet rs,
java.lang.String elementName,
java.lang.String rowDesignator)
throws java.sql.SQLException
rs - The ResultSet that is to be converted into XMLelementName - see aboverowDesignator - see above
java.sql.SQLException - Ya!
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||