XSU updateXML problems
Hi,
I've a table, tab sequence, with the following structures:
Name Null? Type
------------------------------- -------- ----
TABLENAME NOT NULL VARCHAR2(50)
SEQUENCE_NO NUMBER(10)
I've generated an XML document, abc.xml, using the following code segments:
----------------------------------------------------------------------------
import oracle.jdbc.driver.*;
import oracle.xml.sql.query.OracleXMLQuery;
import java.lang.*;
import java.sql.*;
import java.io.*;
// class to test the String generation!
class testXMLSQL {
public static void main(String[] argv)
{
try{
// create the connection
Connection conn = getConnection("john","ajohn");
// Create the query class.
OracleXMLQuery qry = new OracleXMLQuery(conn, "select * from tabsequence");
// Get the XML string
String str = qry.getXMLString();
// Print the XML output to screen
// System.out.println(" The XML output is:\n"+str);
writeToFile("abc.xml",str);
// Always close the query to get rid of any resources..
qry.close();
}catch(SQLException e){
System.out.println(e.toString());
}
}
// Get the connection given the user name and password..!
private static Connection getConnection(String username, String password)
throws SQLException
{
// register the JDBC driver..
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Create the connection using the OCI8 driver
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@10.37.108.122:1220:lslva",username,password);
return conn;
}
private static void writeToFile(String fileName,String fileContent) {
try {
FileOutputStream fo=new FileOutputStream(fileName);
PrintStream ps=new PrintStream(fo);
ps.println(fileContent);
ps.close();
fo.close();
}
catch(Exception ex){
System.out.println(ex);
}
}
}
--------------------------------------------------------------------------
After I've made some modifications to the 'sequence_no' of the abc.xml,
I've attempted to execute the following code segment to update the
tabsequence table:
--------------------------------------------------------------------------
import java.sql.*;
import oracle.xml.sql.dml.OracleXMLSave;
import java.net.*;
public class testUpdate
{
public static void main(String argv[])
throws SQLException
{
String tabName = "tabsequence";
String fileName = "abc.xml";
Connection conn = getConnection("john","ajohn");
OracleXMLSave sav = new OracleXMLSave(conn, tabName);
String [] keyColNames = new String[1];
keyColNames[0] = "TABLENAME";
sav.setKeyColumnList(keyColNames);
String[] updateColNames = new String[2];
updateColNames[0] = "SEQUENCE_NO";
sav.setUpdateColumnList(updateColNames);
URL url = sav.getURL(fileName);
int rowCount = sav.updateXML(url);
sav.close();
System.out.println(" Successfully updated "+rowCount+ " rows into "+ tabName);
conn.close();
}
// Get the connection given the user name and password..!
private static Connection getConnection(String user, String passwd)
throws SQLException
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@10.37.108.122:1220:lslva",user,passwd);
return conn;
}
}
-----------------------------------------------------------------------------
It always gives me the following error message:
Exception in thread "main" oracle.xml.sql.OracleXMLSQLException: NULL NOT A VALID COLUMN NAME.
at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2361)
at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2233)
at oracle.xml.sql.dml.OracleXMLSave.updateXML(OracleXMLSave.java:1595)
at testUpdate.main(testUpdate.java:26)
-------------------------------------------------------------------------------
PLEASE HELP! THANKS