All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----org.xmlmiddleware.xmldbms.DOMToDBMS
DOMToDBMS transfers data from a DOM tree to the database according to a particular XMLDBMSMap and Actions object. The caller must provide a TransferInfo object, which contains the map and database handlers, a DOM Element or Document, and one or more actions to be taken when storing this data in the database.
For example, the following code transfers data from orders.xml according to the map document orders.map and the action document orders.act:
// Create the XMLDBMSMap object with a user-defined function. map = createMap("orders.map"); // Create the Actions object with a user-defined function. actions = createActions(map, "orders.act"); // Create a new DOMToDBMS object. domToDBMS = new DOMToDBMS(); // Create a data source and data handler for our database, then // bundle these into a TransferInfo object. ds = new JDBC1DataSource("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:xmldbms"); handler = new GenericHandler(ds, null, null); ti = new TransferInfo(map, null, handler); // Open the document and call storeDocument to transfer the data. utils = new ParserUtilsXerces(); doc = utils.openDocument(new InputSource(new FileInputStream("orders.xml"))); domToDBMS.storeDocument(ti, doc, actions);
DOMToDBMS stores data starting with the first element it finds that is mapped as a class. It continues processing along a given branch until it finds an element that is not mapped. It then continues with the sibling of that element. Thus, DOMToDBMS stores data from one or more contiguous fragments of the DOM tree.
Applications call this method only if the map requires XML-DBMS to generate primary keys.
public DOMToDBMS()
public void setCommitMode(int commitMode)
The commit mode must be one of DataHandler.COMMIT_AFTERSTATEMENT, COMMIT_AFTERDOCUMENT, COMMIT_NONE, or COMMIT_NOTRANSACTIONS. The default is COMMIT_AFTERSTATEMENT.
public int getCommitMode()
public void setFilterSetReturned(boolean value)
storeDocument can return a FilterSet describing the document it processes. This can be used at a later point in time to retrieve the document. Whether such a FilterSet is useful depends on the application. As a general rule, it is not useful for data-centric applications. For these applications, XML is usually a data transport and documents have no persistent identity. It is useful for document-centric applications, for which documents do have a persistent identity.
By default, storeDocument returns a null. This saves some processing time, although the amount saved is likely to be noticeable only for very large documents.
public boolean isFilterSetReturned()
For more information, see setFilterSetReturned.
public void addKeyGenerator(String name, KeyGenerator generator)
Applications call this method only if the map requires XML-DBMS to generate primary keys. (This does not include database-generated keys.)
public void removeKeyGenerator(String name)
public void removeAllKeyGenerators()
public void stopOnException(boolean stopOnException)
When an exception occurs, one of two things happens. If this is set to false, then the exception is added to the list returned by getExceptions and processing continues at the next class element. If this is set to true, then processing stops at the first exception.
By default, processing stops on exceptions.
public SQLWarning getWarnings()
public SQLException getExceptions()
public FilterSet storeDocument(TransferInfo transInfo, Document doc, int action) throws SQLException, XMLMiddlewareException
public FilterSet storeDocument(TransferInfo transInfo, Document doc, Actions actions) throws SQLException, XMLMiddlewareException
public FilterSet storeDocument(TransferInfo transInfo, Element el, int action) throws SQLException, XMLMiddlewareException
public FilterSet storeDocument(TransferInfo transInfo, Element el, Actions actions) throws SQLException, XMLMiddlewareException
All Packages Class Hierarchy This Package Previous Next Index