Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Overview of this book

Table of Contents (20 chapters)
JDBC 4.0 and Oracle JDeveloper for J2EE Development
Credits
About the Author
About the Reviewer
Preface

Updating Database from XML Document


In this section, we will update a database table from an XML document, using the OracleXMLSave class, and create an OracleXMLSave object using a Connection object. JOURNAL is the database table that has to be modified.

OracleXMLSave oracleXMLSave =new OracleXMLSave(conn, "JOURNAL");

Set the row enclosing element tag using the setRowTag(String) method, and set the row tag to journal. Also set ignore case to true.

oracleXMLSave.setRowTag("journal");
oracleXMLSave.setIgnoreCase(true);

Set key columns using the setKeyColumnList(String[]) method and set CATALOGID as a key column.

String [] keyColNames = new String[1];
keyColNames[0] = "CATALOGID";
oracleXMLSave.setKeyColumnList(keyColNames);

Specify an array of columns to be updated, and also specify the columns to be updated using the setUpdateColumnList(String[]) method. We will modify the EDITION column and the TITLE column with an XML document.

String[] updateColNames = new String[2];
updateColNames...