|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.etools.xmltosql.XMLToSQL
XMLToSQL is used to insert, update, or delete rows in a database table using an XML document. The mapping between the XML structure to the table structure is based on a set of simple mapping rules. The following XML fragment illustrates the mapping rules:
<rootElement> <EMPLOYEE> <FIRSTNAME>CHRISTINE</FIRSTNAME> <LASTNAME>HAAS</LASTNAME> </EMPLOYEE> <EMPLOYEE> <FIRSTNAME>MICHAEL</FIRSTNAME> <LASTNAME>THOMPSON</LASTNAME> </EMPLOYEE> ... </rootElement>
Constructor Summary | |
XMLToSQL(SQLProperties sqlProperties)
This is the only constructor. |
Method Summary | |
void |
addToKeyColumns(java.lang.String columnName)
Adds to the list of the key column names that will be used in building the where-clause for UPDATE or DELETE. |
void |
addToUpdateColumns(java.lang.String columnName)
Adds to the list of the column names that will be updated or inserted. |
void |
execute(org.w3c.dom.Document doc,
boolean continueOnSQLError)
Updates a table from a DOM Document. |
void |
execute(java.io.InputStream inputStream)
Updates a table from an XML input stream. |
void |
execute(java.io.InputStream inputStream,
boolean continueOnSQLError)
Updates a table from an XML input stream. |
void |
execute(java.lang.String filename)
Updates a table from an XML file. |
void |
execute(java.lang.String filename,
boolean continueOnSQLError)
Updates a table from an XML file. |
void |
finalize()
Closes the connection if this was created internally. |
java.util.Vector |
getFailedStatements()
Returns a collection of SQL statements that have been failed during execution. |
java.lang.String |
getTableName(java.io.InputStream inputStream)
Returns the database table name to be updated. |
java.lang.String |
getTableName(java.lang.String filename)
Returns the database table name to be updated. |
void |
setConnection(java.sql.Connection jdbcConnection)
Provides a JDBC connection to be used for updating the tables. |
void |
setTrace(boolean flag)
Sets the trace flag. |
void |
setTrace(boolean flag,
java.io.PrintWriter writer)
Sets the trace flag. |
boolean |
updateMultipleRows(java.lang.String uri,
java.util.Vector keys)
Determines if multiple rows would be updated/deleted once any of the execute() method was called. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XMLToSQL(SQLProperties sqlProperties)
sqlProperties
- Contains information for the update.SQLProperties
Method Detail |
public void execute(java.lang.String filename) throws java.sql.SQLException, java.io.FileNotFoundException, java.lang.ClassNotFoundException, java.io.IOException, org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
filename
- XML filename.java.sql.SQLException
- DDL execution failed.java.io.FileNotFoundException
- Input XML file was not found.java.lang.ClassNotFoundException
- JDBC driver could not be found.java.io.IOException
- Corrupted XML file.SAXException
- The XML content of the input file may not be well-formed.javax.xml.parsers.ParserConfigurationException
- Could not find an XML parser.public void execute(java.lang.String filename, boolean continueOnSQLError) throws java.sql.SQLException, java.io.FileNotFoundException, java.lang.ClassNotFoundException, java.io.IOException, org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
filename
- XML filename.continueOnSQLError
- Used to choose a transaction mode.java.sql.SQLException
- DDL execution failed.java.io.FileNotFoundException
- Input XML file was not found.java.lang.ClassNotFoundException
- JDBC driver could not be found.java.io.IOException
- Corrupted XML fileSAXException
- The XML content of the input file may not be well-formed.javax.xml.parsers.ParserConfigurationException
- Could not find an XML parser.getFailedStatements()
public void execute(java.io.InputStream inputStream) throws java.sql.SQLException, java.lang.ClassNotFoundException, java.io.IOException, org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
inputStream
- XML input stream.java.sql.SQLException
- DDL execution failed.java.lang.ClassNotFoundException
- JDBC driver could not be found.java.io.IOException
- Corrupted XML streamSAXException
- The XML content of the input stream may not be well-formed.javax.xml.parsers.ParserConfigurationException
- Could not find an XML parser.public void execute(java.io.InputStream inputStream, boolean continueOnSQLError) throws java.sql.SQLException, java.lang.ClassNotFoundException, java.io.IOException, org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
inputStream
- XML input stream.continueOnSQLError
- Used to choose a transaction mode.java.sql.SQLException
- DDL execution failed.java.lang.ClassNotFoundException
- JDBC driver could not be found.java.io.IOException
- Corrupted XML streamSAXException
- The XML content of the input stream may not be well-formed.javax.xml.parsers.ParserConfigurationException
- Could not find an XML parser.getFailedStatements()
public void execute(org.w3c.dom.Document doc, boolean continueOnSQLError) throws java.sql.SQLException, java.lang.ClassNotFoundException, java.io.IOException, org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
doc
- DOM Document.continueOnSQLError
- Used to choose a transaction mode.java.sql.SQLException
- DDL execution failed.java.lang.ClassNotFoundException
- JDBC driver could not be found.java.io.IOException
- Corrupted XML streamSAXException
- The XML content of the input stream may not be well-formed.javax.xml.parsers.ParserConfigurationException
- Could not find an XML parser.getFailedStatements()
public void setConnection(java.sql.Connection jdbcConnection)
jdbcConnection
- A JDBC connectionpublic java.util.Vector getFailedStatements()
public void finalize()
setConnection(java.sql.Connection)
public void setTrace(boolean flag)
flag
- true to show the trace, false otherwise.public void setTrace(boolean flag, java.io.PrintWriter writer)
flag
- true to show the trace, false otherwise.writer
- A PrintWriter where the trace output is directed to.public java.lang.String getTableName(java.lang.String filename) throws java.io.IOException, org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
filename
- XML file namejava.io.IOException
- Corrupted XML streamSAXException
- The XML content of the input stream may not be well-formed.javax.xml.parsers.ParserConfigurationException
- Could not find an XML parser.public java.lang.String getTableName(java.io.InputStream inputStream) throws java.io.IOException, org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
inputStream
- XML input streamjava.io.IOException
- Corrupted XML streamSAXException
- The XML content of the input stream may not be well-formed.javax.xml.parsers.ParserConfigurationException
- Could not find an XML parser.public void addToKeyColumns(java.lang.String columnName) throws java.lang.Exception
columnName
- A column name to be used in the where-clause for UPDATE
or DELETE.java.lang.Exception
- The column in the update column list cannot be used
as a key column.addToUpdateColumns(java.lang.String)
public void addToUpdateColumns(java.lang.String columnName) throws java.lang.Exception
columnName
- A column name to be updated or inserted in the table.java.lang.Exception
- The column in the key column list cannot be used as
an update column.addToKeyColumns(java.lang.String)
public boolean updateMultipleRows(java.lang.String uri, java.util.Vector keys) throws java.lang.Exception
uri
- A source XML filenamekeys
- The key column names to be used in the where-clause for
UPDATE/DELETE.java.lang.Exception
- Failed while processing the source XML file.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |