• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2499
  • Last Modified:

XML-0108: (Fatal Error) Start of root element expected.

hi
i ahve a oracle 8.1.7.0.0 data base
i am trying to Load XMl into the Database


This is my program


import java.sql.*;
import oracle.xml.sql.dml.OracleXMLSave;
import java.util.*;
import oracle.jdbc.driver.*;

public class testInsert
{
   public static void main(String argv[])
     throws SQLException
  {
     DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
     Connection con = DriverManager.getConnection("jdbc:oracle:thin:@DLS702:1521:OMS", "scott", "tiger");
     OracleXMLSave sav = new OracleXMLSave(con, "emp");
     sav.insertXML("D:/radhika/javatry/test.xml");
     sav.close();
   }
}


this is the xml
<?xml version="1.0" >
<ROWSET>
   <ROW num="1">
      <EMPNO>8782</EMPNO>
      <ENAME>Clark</ENAME>
      <JOB>Manager</JOB>
      <MGR>7839</MGR>
      <HIREDATE>6/9/1981 0:0:0</HIREDATE>
      <SAL>2572.5</SAL>
      <COMM>20</COMM>
      <DEPTNO>10</DEPTNO>
      <PROJNO>101</PROJNO>
      <LOADSEQ>1</LOADSEQ>
   </ROW>
   <ROW num="2">
      <EMPNO>8839</EMPNO>
      <ENAME>King</ENAME>
      <JOB>President</JOB>
      <HIREDATE>11/17/1981 0:0:0</HIREDATE>
      <SAL>5500</SAL>
      <COMM>-10</COMM>
      <DEPTNO>10</DEPTNO>
      <PROJNO>102</PROJNO>
      <LOADSEQ>2</LOADSEQ>
   </ROW>
   <ROW num="3">
      <EMPNO>8934</EMPNO>
      <ENAME>Miller</ENAME>
      <JOB>Clerk</JOB>
      <MGR>7782</MGR>
      <HIREDATE>1/23/1982 0:0:0</HIREDATE>
      <SAL>920</SAL>
      <DEPTNO>10</DEPTNO>
      <PROJNO>102</PROJNO>
      <LOADSEQ>3</LOADSEQ>
   </ROW>
</ROWSET>


how ever when i run it i get this error
<Line 1, Column 1>: XML-0108: (Fatal Error) Start of root element expected.
Exception in thread "main" oracle.xml.sql.OracleXMLSQLException: Start of root element expected.
        at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2204)
        at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1276)
        at testInsert.main(testInsert.java:14)


what could be the reason and if any solution?
0
violet1306
Asked:
violet1306
  • 2
  • 2
1 Solution
 
BigRatCommented:
I don't know if this is a question typo but :-

<?xml version="1.0" >
<ROWSET>


should read :-

<?xml version="1.0"?>
<ROWSET>

Note the second question mark.
0
 
violet1306Author Commented:
i tried  this , it didn't work  ?

is it because of the oracle version that i am using?
0
 
BigRatCommented:
Ooops, missed it first time round.

The method insertXML with a *string* parameter expects an XML document in the string. The overloaded insertXML method does NOT take a filename. You must create a java.io.InputStream object and pass that instead.
0
 
violet1306Author Commented:
thanx it worked
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now