?
Solved

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

Posted on 2005-03-01
4
Medium Priority
?
2,417 Views
Last Modified: 2011-10-03
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
Comment
Question by:violet1306
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:BigRat
ID: 13439365
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
 

Author Comment

by:violet1306
ID: 13446681
i tried  this , it didn't work  ?

is it because of the oracle version that i am using?
0
 
LVL 27

Accepted Solution

by:
BigRat earned 500 total points
ID: 13448171
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
 

Author Comment

by:violet1306
ID: 13456090
thanx it worked
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Make the most of your online learning experience.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses
Course of the Month7 days, 20 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question