| java.lang.Object com.quadcap.sql.tools.XmlLoad
XmlLoad | public class XmlLoad implements DocumentHandler,ErrorHandler(Code) | | This class implements the reverse functionality of XmlDump -- it loads
a database with the data contained in the specified XML file.
author: Stan Bailes |
COLUMN | final static int COLUMN(Code) | | |
DATABASE | final static int DATABASE(Code) | | |
TABLE | final static int TABLE(Code) | | |
hexMap | static byte[] hexMap(Code) | | |
XmlLoad | public XmlLoad() throws Exception(Code) | | No-argument constructor. The new object needs a database connection
before it can do anything useful.
exception: Exception - may be thrown if there's a problem constructingthe XML parser. |
XmlLoad | public XmlLoad(Connection conn) throws Exception(Code) | | Construct a new XmlLoad object bound to the specified
connection
Parameters: conn - the database connection exception: Exception - may be thrown if there's a problem constructingthe XML parser. |
characters | public void characters(char[] ch, int start, int length) throws SAXException(Code) | | SAX parser callback to handle character data found in the
parsed document.
Parameters: ch - the buffer containing the parsed characters. Parameters: star - the buffer position of the first character Parameters: length - the number of characters exception: SAXException - may be thrown if this data representsa database value and there's a SQL exception thrown whiletrying to update the underlying resultset object with thisdata. |
endDocument | public void endDocument()(Code) | | SAX parser callback function that is called when the end of the
document is reached. This implementation does nothing.
|
endElement | public void endElement(String name) throws SAXException(Code) | | SAX parser callback function called for the end of an element.
If this element
represents the <database> element, we finish up
by closing the active statement. If this element represents a table
row element, we insert the current row. Otherwise, we do nothing.
Parameters: name - the name of this element exception: SAXException - may be thrown to wrap any underlying databaseexception. |
error | public void error(SAXParseException exception)(Code) | | SAX parser callback to handle XML Parser errors.
This implementation just prints them
to System.err.
Parameters: exception - the exception generated by the parser. |
fatalError | public void fatalError(SAXParseException exception)(Code) | | SAX parser callback to handle XML Parser fatal errors.
This implementation just prints them
to System.err.
Parameters: exception - the exception generated by the parser. |
getConnection | public Connection getConnection()(Code) | | Get the loader's database connection
the current database connection |
ignorableWhitespace | public void ignorableWhitespace(char[] ch, int start, int length)(Code) | | SAX parser callback for ignorable whitespace. We just ignore it
Parameters: ch - the buffer containing the parsed characters. Parameters: star - the buffer position of the first character Parameters: length - the number of characters |
load | public void load(InputStream is) throws Exception(Code) | | Load the XML document from the specified input stream, importing the
data contained therein into the database referenced by the current
connection. The input document should be a well-formed XML
<database> document.
Parameters: is - the input stream containing the XML document. exception: Exception - may be thrown if there's a parse error ora database error. |
load | public void load(Reader r) throws Exception(Code) | | Load the XML document from the specified reader, importing the
data contained therein into the database referenced by the current
connection. The input document should be a well-formed XML
<database> document.
Parameters: r - the input reader containing the XML document. exception: Exception - may be thrown if there's a parse error ora database error. |
main | public static void main(String[] args)(Code) | | A main program which supports the command-line invocation of either
the Loader or XmlLoad functions. This function accepts
one or more file names as arguments.
For each file name that ends with the ".sql" extension,
the Loader.loadFile() method is invoked
to execute the SQL commands in the file.
For each file name that ends with the ".xml"
or ".xml.gz" extension, the
XmlLoad.load() method is invoked to
load the XML data from that file into the database.
Parameters: args - database-name file ... |
processingInstruction | public void processingInstruction(String target, String data)(Code) | | SAX parser callback for processing instructions. This implementation
does nothing.
Parameters: target - the processing instruction target. Parameters: data - the processing instruction data. |
setConnection | public void setConnection(Connection conn) throws SQLException(Code) | | Set the loader's database connection
Parameters: conn - the new database connection exception: SQLException - may be thrown |
setDocumentLocator | public void setDocumentLocator(Locator locator)(Code) | | SAX parser callback used to receive a document locator.
Parameters: locator - the parser's locator object. |
startDocument | public void startDocument()(Code) | | SAX parser callback for document start.
This implementation does nothing.
|
startElement | public void startElement(String name, AttributeList attrs) throws SAXException(Code) | | SAX parser callback for the start of an element. If this element
represents a table row, and the table is different from the last
table seen, we establish an updatable ResultSet for the
new table which can be used to insert new rows into the table.
If this element represents a table row, we move to the insert row.
If this element represents a column, we remember the column name.
Parameters: name - the element name Parameters: attrs - the element's attributes exception: SAXException - may be thrown to wrap an underlying databaseerror, or if there is a problem with the XML document itself. |
warning | public void warning(SAXParseException exception)(Code) | | SAX parser callback to handle XML Parser fatal errors.
This implementation just prints them
to System.err.
Parameters: exception - the exception generated by the parser. |
|
|