How to store xml-file direct on file-directory on server ?

Hello,
I have created a xml-data by using xmlelements, xmlforest .... and so on in a sql-statement and want to store it as file in a ( windows) server-directory.
I can find some samples to store it in XML-DB by using dbms_xmlGEN and dbms_XDB,
but how to store it direct ?
thank you
Norbert

Try dbms_xmldom.writeToFile()..
Or create a resource from your SQL Statement using dbms_xdb.createResource() and then access the resource via FTP or HTTP

Similar Messages

  • How to store xml data into file in xml format through java program?

    HI Friends,
    Please let me know
    How to store xml data into file in xml format through java program?
    thanks......
    can discuss further at messenger.....
    Avanish Kumar Singh
    Software Engineer,
    Samsung India Development Center,
    Bangalore--560001.
    [email protected]

    Hi i need to write the data from an XML file to a Microsoft SQL SErver database!
    i got a piece of code from the net which allows me to parse th file:
    import java.io.IOException;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import org.apache.xerces.parsers.SAXParser;
    import java.lang.*;
    public class MySaxParser extends DefaultHandler
    private static int INDENT = 4;
    private static String attList = "";
    public static void main(String[] argv)
    if (argv.length != 1)
    System.out.println("Usage: java MySaxParser [URI]");
    System.exit(0);
    String uri = argv[0];
    try
    XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    MySaxParser MySaxParserInstance = new MySaxParser();
    parser.setContentHandler(MySaxParserInstance);
    parser.parse(uri);
    catch(IOException ioe)
    ioe.printStackTrace();
    catch(SAXException saxe)
    saxe.printStackTrace();
    private int idx = 0;
    public void characters(char[] ch, int start, int length)
    throws SAXException
    String s = new String(ch, start, length);
    if (ch[0] == '\n')
    return;
    System.out.println(getIndent() + " Value: " + s);
    public void endDocument() throws SAXException
    idx -= INDENT;
    public void endElement(String uri, String localName, String qName) throws SAXException
    if (!attList.equals(""))
    System.out.println(getIndent() + " Attributes: " + attList);
    attList = "";
    System.out.println(getIndent() + "end document");
    idx -= INDENT;
    public void startDocument() throws SAXException
    idx += INDENT;
    public void startElement(String uri,
    String localName,
    String qName,
    Attributes attributes) throws SAXException
    idx += INDENT;
    System.out.println('\n' + getIndent() + "start element: " + localName);
    if (localName.compareTo("Machine") == 0)
    System.out.println("YES");
    if (attributes.getLength() > 0)
    idx += INDENT;
    for (int i = 0; i < attributes.getLength(); i++)
    attList = attList + attributes.getLocalName(i) + " = " + attributes.getValue(i);
    if (i < (attributes.getLength() - 1))
    attList = attList + ", ";
    idx-= INDENT;
    private String getIndent()
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < idx; i++)
    sb.append(" ");
    return sb.toString();
    }// END PRGM
    Now , am not a very good Java DEv. and i need to find a soln. to this prob within 1 week.
    The next step is to write the data to the DB.
    Am sending an example of my file:
    <Start>
    <Machine>
    <Hostname> IPCServer </Hostname>
    <HostID> 80c04499 </HostID>
    <MachineType> sun4u [ID 466748 kern.info] Sun Ultra 5/10 UPA/PCI (UltraSPARC-IIi 360MHz) </MachineType>
    <CPU> UltraSPARC-IIi at 360 MHz </CPU>
    <Memory> RAM : 512 MB </Memory>
    <HostAdapter>
    <HA> kern.info] </HA>
    </HostAdapter>
    <Harddisks>
    <HD>
    <HD1> c0t0d0 ctrl kern.info] target 0 lun 0 </HD1>
    <HD2> ST38420A 8.2 GB </HD2>
    </HD>
    </Harddisks>
    <GraphicCard> m64B : PCI PGX 8-bit +Accel. </GraphicCard>
    <NetworkType> hme0 : Fast-Ethernet </NetworkType>
    <EthernetAddress> 09:00:30:C1:34:90 </EthernetAddress>
    <IPAddress> 149.51.23.140 </IPAddress>
    </Machine>
    </Start>
    Note that i can have more than 1 machines (meaning that i have to loop thru the file to be able to write to the DB)
    Cal u tellme what to do!
    Even better- do u have a piece of code that will help me understand and implement the database writing portion?
    I badly need help here.
    THANX

  • I have a 2tb time capsule wondering how to store a lot of my files and photos on it to free up some space on my hard drive on my iMac

    i have a 2tb time capsule wondering how to store a lot of my files and photos on it to free up some space on my hard drive on my iMac

    For iMac please use USB or even better a FW800 or if you can afford it, a thunderbolt drive.. on your 2011 Mac.
    Time Capsule is not a suitable place to store your files.
    1. You will have no backup.
    2. TC cannot back itself up, nor can Time Machine backup network drives.
    3. Apple says specifically of iphoto not to store library on network drive.
    iphoto network no no.
    http://support.apple.com/kb/HT1198
    It's recommended that you store your iPhoto library on a locally mounted hard drive. Storing your iPhoto library on a network share can lead to poor performance, data corruption, or data loss.
    https://discussions.apple.com/thread/6692100
    4. Other libraries may not corrupt but will run very slowly. iTunes for example.
    Please purchase the fastest drive out of the external ports you have available.. usb2 although the slowest is still faster than TC over gigabit. It is also more reliable. TC are not a noted reliable storage drive. It is designed as a backup location for TM files.

  • How to store XML files

    Hi experts,
    I have an abap applicatrion that has to store xml files received from a web service.
    Where is better to store these files, in sap transparent tables or in the IXOS for example?
    Thanks

    Brad,
    An java application will call that BAPI passing the XML when error occurs in the process. The XML will contain the error details.
    I want to associate the error messages with the respective XMLs.
    What do you mean with  "object type / object value" ?
    Thanks
    Edited by: Jorge Castro on Jan 18, 2011 5:09 PM

  • How to store the contents of a file

    Hi,
    I'm using forms6i and database 10g.
    Through forms if a user selects a filename , and clicks a button or something,
    the contents of the file should be saved in the database.
    The file can be of any type, like .doc,.pdf,.xml,.html etc...
    and the contents filed will be of type varchar
    Please help me do this..
    Thanks

    Do you really want to save the "Content" of a file or the file itself? If you try to save the contents of a .doc or .pdf in a column with a VARCHAR2 datatype, you are going to corrupt the contents of the file since these file types have binary data in them as well as text. I think you would have greater success storing the actual file in a BLOB column.
    Here are a few Oracle Support documents that discuss how to store and retrieve files stored as BLOBs in the database.
    Doc ID: 168277.1 - How to Upload Binary Documents Back to Database BLOB Column from Forms
    Doc ID: 330146.1 - How to write BLOBs Stored Inside the Database Out to Files.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • How to store the data of a file into an ArrayList?

    Hi! everyone.
    I want to know
    if I have a File, and the data in the file are type int, type String...
    And I have a ArrayList which is of type Question
    How do I store the data of that file into the ArrayList
    I tried to use the while loop(use the hasNextLine() to read the data line by line)
    But I cannot add data which are not of type Question to the ArrayList.
    Can you tell me what I should do, please?
    I also wonder that
    The data of the file are of many types, but when I try to read it with the nextLine(), the data all turn out to be of type String. Why?
    Thank you.
    Edited by: Terry001 on Apr 30, 2008 1:13 PM

    No, a line in the file is just part of a question
    The format of the file is like this:
    *<question type code>                    :     String*
    *<question point value>                    :     int*
    *<question category>                         :     String*
    *<question difficulty level>               :     int*
    *<question text>                              :     String*
    *<question correct answer>               :     String*
    *<optional question-specific data>     :     String*
    *<question terminator>                    :     String*
    And here is an example
    TF //TrueFalseQuestion
    5 //points value
    None //category
    3 //difficulty level
    The capital of the United States is Washington, D.C. //question text
    True // answer
    *** //quetion terminator
    I created an ArrayList in the Test class:
    private ArrayList<Question> questions; // Create inside constructor
        public Test (String name, String instr)
            testName = name;
            scoreEarned = 0;
            scorePossible = 0;
            instructions = instr;
            questions = new ArrayList<Question>(); //[MAX_NUMBER_OF_QUESTIONS];
        }And I tried to use the following method to store the data of the file to the ArrayList
    // This method loads a set of questions from a plain text file
        public void loadQuestionsFromFile(String fileName) throws FileNotFoundException
            try
                File fileReader = new File("input.txt");
                Scanner sc = new Scanner(fileReader);
                while (sc.hasNextLine())
                    // I don't know how to pass the data I got from the nextLine() method to the ArrayList because they are of different type
            catch (FileNotFoundException a)
                System.out.println(a);
        }    As all you said, I should create an Question object in the while loop
    Question temp = new Question ();But I have no idea how to pass the int and String to the Question object.
    Thank you

  • How to store grid points in a file using Java Swing?

    Please someone help me with any suggestions about how to store the grid points in a file using Java Swing

    Actually i have designed a gridlayout in Java Swing and have added some components to it such as buttons or images....My problem is when I click on any of the cell of the grid,the corresponding cell number should be stored in an external file....Do u have any suggestions on how to do it?

  • Don't know how to store/show image or pdf files easily in apex app

    Hi,
    I always want to put a blob column in my table and store some images or pdf files, like drawings for an item, but I found it hard to do, I have viewed the sample app by apex 4.0, but I cannot understand the code.
    Is there a simple and intuitive way of storing/showing pdf files in an apex app?
    I wish Oracle could make an easier wizard for apex on that issue.
    just make storing a file as simple as in MS access, or email attachment, etc.
    no headache coding involved.
    that will be great!
    that will also do Oracle good, since images will use up a lot of spaces, maybe Xe won't be enough, the will consider an upgrade.

    Yawei,
    there is a chapter about BLOB support in the application builder users guide: http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/advnc.htm#BCGGJHEF
    Maybe this helps for a start, even if it isn't as easy as in MsAccess but this may be due to the fact that APEX is a web application and Access a rich client.
    brgds,
    Peter
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    BuilderPlugin: http://builderplugin.oracleapex.info
    Work: http://www.click-click.at

  • How to write xml data to a file

    Hi all,
    We have a requirement of writing the xml data into a file in given directory in the server. Generating the xml data using the sql query below.
    SELECT XMLELEMENT ("ROW",
    XMLELEMENT ("CELL", xmlattributes ('EBIZCZMDL_01' AS "colname"), inventory_item_id),
    XMLELEMENT ("CELL", xmlattributes ('EBIZFFMT_01' AS "COLNAME"), attribute29),
    XMLELEMENT ("CELL", xmlattributes ('COMMON' AS "COLNAME"),inventory_item_id || '' || attribute29 || 'ITM')
    AS "RESULT") "XMLDATA"
    FROM apps.mtl_system_items_b
    When we try to write the the data from this query to a file using UTL_FILE.put_line, the script gives the error
    PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
    If somebody can help us pls.......
    Thanks in advance

    Hi Odie,
    We are looking at the xml data to be like the below:
    - <xref xmlns="http://xmlns.oracle.com/xref">
    - <table name="NAPP_ITEM_ITEMID">
    - <columns>
    <column name="EBIZFFMT_01" />
    <column name="COMMON" />
    <column name="EBIZQOT_01" />
    <column name="EBIZCZMDL_01" />
    <column name="EBIZCZGOLD_01" />
    </columns>
    - <rows>
    - <row>
    <cell colName="EBIZFFMT_01">154</cell>
    <cell colName="COMMON">154811809990111362727</cell>
    <cell colName="EBIZQOT_01">81</cell>
    <cell colName="EBIZCZMDL_01">91</cell>
    <cell colName="EBIZCZGOLD_01">991</cell>
    </row>
    - <row>
    <cell colName="EBIZFFMT_01">180</cell>
    <cell colName="COMMON">180811809990111362727</cell>
    <cell colName="EBIZQOT_01">871</cell>
    <cell colName="EBIZCZMDL_01">731</cell>
    <cell colName="EBIZCZGOLD_01">341</cell>
    </row>
    </rows>
    </table>
    </xref>
    We have managed half way trying to get the structure. As we are new to this XML Programming.
    The call to dbms_xslprocessor.clob2file is within the cursor loop for the given SQL.
    DECLARE
    l_file_name VARCHAR2 (30);
    l_file_path VARCHAR2 (200);
    CURSOR xml_cur
    IS
    SELECT XMLELEMENT
    ("ROW",
    XMLELEMENT ("CELL",
    xmlattributes ('EBIZCZMDL_01' AS "colname"),
    inventory_item_id
    XMLELEMENT ("CELL",
    xmlattributes ('EBIZFFMT_01' AS "COLNAME"),
    attribute29
    XMLELEMENT ("CELL",
    xmlattributes ('COMMON' AS "COLNAME"),
    inventory_item_id || '' || attribute29 || 'ITM'
    ) AS "RESULT"
    ) "XMLDATA"
    FROM apps.mtl_system_items_b
    WHERE attribute29 IS NOT NULL;
    BEGIN
    l_file_path := '/usr/tmp';
    l_file_name := 'TEST_XREF4.xml';
    FOR xml_rec IN xml_cur
    LOOP
    dbms_xslprocessor.clob2file(xml_rec.XMLDATA, l_file_path, l_file_name, nls_charset_id('UTF8') );
    END LOOP;
    END;
    Please see the above code snippet and help us if we are doing something wrong.
    Thank you

  • How to Parse XML data directly from context variables in webdynpro

    Hello,
       I have two requirements:
    1) I have a context variable which has string value.
       I want to write the this value into a flat file.
       How do I do this in WebDynpro.
       Any sample code for this.
    2) In Webdynpro, I want to parse and process the XML data directly from a string context variable which
       has the value in XML format.
       How do I achieve this. Any pointers or sample codes for this.
    Thanks and Regards,
    Anupama.

    Anupama,
    Here is some link which talks about unpacking xml and converting to HTML.
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/eb/3dfb402eb5f76fe10000000a1550b0/content.htm">http://help.sap.com/saphelp_nw04/helpdata/en/eb/3dfb402eb5f76fe10000000a1550b0/content.htm</a>
    I have done something like this in portal development and not in webdynpro.But in principle it should work very where.

  • How to store XML data into Oracle Table

    I had trouble to store XML data into Oracle Table with XDK (Oracle 8.1.7 ). The error is:
    C:\XDK_Java_9_2\xdk\demo\java\Test>java testInsert Dept.xml
    <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:2263)
    at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1333)
    at testInsert.main(testInsert.java:8)
    Here is my xml file:
    <?xml version = '1.0'?>
    <ROWSET>
    <ROW num="1">
    <DEPTNO>10</DEPTNO>
    <DNAME>ACCOUNTING</DNAME>
    <LOC>NEW YORK</LOC>
    </ROW>
    <ROW num="2">
    <DEPTNO>20</DEPTNO>
    <DNAME>RESEARCH</DNAME>
    <LOC>DALLAS</LOC>
    </ROW>
    <ROW num="3">
    <DEPTNO>30</DEPTNO>
    <DNAME>SALES</DNAME>
    <LOC>CHICAGO</LOC>
    </ROW>
    <ROW num="4">
    <DEPTNO>40</DEPTNO>
    <DNAME>OPERATIONS</DNAME>
    <LOC>BOSTON</LOC>
    </ROW>
    </ROWSET>
    and here is structure of table:
    Name Null? Type
    DEPTNO NOT NULL NUMBER(2)
    DNAME VARCHAR2(14)
    LOC VARCHAR2(13)
    and here is my Java Code:
    import java.sql.*;
    import oracle.xml.sql.dml.OracleXMLSave;
    public class testInsert{
         public static void main(String[] args) throws SQLException{
              Connection conn = getConnection();
              OracleXMLSave sav = new OracleXMLSave(conn,"scott.tmp_dept");
              sav.insertXML(args[0]);
              sav.close();
              conn.close();
         private static Connection getConnection()throws SQLException{
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
              Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@amt-ebdev01:1521:mydept","scott","tiger");
              return conn;
    Could you help me ? Thanks !

    The problem is that you need to pass avalid URL , Document...
    Please try this code instead:
    import java.net.*;
    import java.sql.*;
    import java.io.*;
    import oracle.xml.sql.dml.OracleXMLSave;
    public class testInsert
    public static void main(String[] args) throws SQLException{
    Connection conn = getConnection();
    OracleXMLSave sav = new OracleXMLSave(conn,"scott.temp_dept");
    URL url = createURL(args[0]);
    sav.insertXML(url);
    sav.close();
    conn.close();
    private static Connection getConnection()throws SQLException{
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@dlsun1982:1521:jwxdk9i","scott","tiger");
    return conn;
    // Helper method to create a URL from a file name
    static URL createURL(String fileName)
    URL url = null;
    try
    url = new URL(fileName);
    catch (MalformedURLException ex)
    File f = new File(fileName);
    try
    String path = f.getAbsolutePath();
    // This is a bunch of weird code that is required to
    // make a valid URL on the Windows platform, due
    // to inconsistencies in what getAbsolutePath returns.
    String fs = System.getProperty("file.separator");
    if (fs.length() == 1)
    char sep = fs.charAt(0);
    if (sep != '/')
    path = path.replace(sep, '/');
    if (path.charAt(0) != '/')
    path = '/' + path;
    path = "file://" + path;
    url = new URL(path);
    catch (MalformedURLException e)
    System.out.println("Cannot create url for: " + fileName);
    System.exit(0);
    return url;

  • Can't open files directly from file server (MAVERICKS)

    since updating to Mavericks earlier today i have had the below problem
    I use a file server at work to access all my work files. i have no problem accessing the servers but when i try and when I double click to open a file (excel, word, pdf, etc) it says "the application cant be found"
    when Ihave the application open and i open the same file from within the application (file > open) it works fine. I just cannot open files directly from the file server by double clicking.
    in previous versions there have been no problems with this,
    any help would be great,

    Same issue here; I hadn't related it to upgrading to the latest OS 10.9.2. I've shutdown and restared multiple times. I've also rebuilt permissions on my hard drive as I thought it was the Finder but files on my local HD open file. Off the server, I cannot double-click or even drag to the dock. Files open fine if I open the app first then browse to find the file.

  • How To Store XML Fragments Using Functions Such As XMLElement

    Hi
    Not sure what I am missing. I wish to store XML fragments in variables so can pass around and concatenate with other fragments to make final XML document. Even before attempting to concatenate XML fragments, I am struggling to store any XML fragment in a variable. I am trying to use simple functions such as XMLElement to generate XML so can store in variable. I have seen many examples of XMLElement in SQL select statement. Can XMLElement be used in plsql? XMLElement says it returns value of type XMLType. Functions such as XMLElement make generating XML easier than creating all tags manually.
    Below is simple example that demonstrates what I would like to do. I would like to be able to pass the XML fragment as either XMLType or clob. I receive error saying PLS-00201: identifier 'XMLELEMENT' must be declared
    declare
    vTheData XMLType;
    vTheDataClob clob;
    begin
      vTheData:= XMLelement("empno",'1234567');
      vTheDataClob:= xmlelement("empno",'1234567').getclobval();
    end;
    Where as I can use below, but surely don't have to use select into from dual method. I just expect can use XMLElement function in plsql same as sql, such as most other functions eg length, rtrim etc.
    declare
    vTheData XMLType;
    vTheDataClob clob;
    begin
      select xmlelement("empno",'1234567')
      into vTheData
      from dual;
      select xmlelement("empno",'1234567').getclobval()
      into vTheDataClob
      from dual;
    end;
    Hope this makes sense.
    Thanks

    Having said that, is there a more elegant way to achieve below. That is populate two XML fragments and concatenate together.
    Sure, why not just only one statement?
    select XMLConcat(
             XMLElement( ... )
           , XMLElement( ... )
    into vTheResult
    from dual;
    As a second question, is it better to build and pass XML fragments as XMLType or clob?
    I would say stay with XMLType but it depends on your requirement.
    I generally avoid passing around pieces of data, SQL/XML functions are powerful in the way they can be used with set operations, so using them in a piecewise approach kinda negates what they're for.

  • How to store xml data fragments, that will not be queried?

    Hello,
    Delphi Client application communicates with Java Server application via XML messages. Client sends XML message over HTTP Post method. Java Servlet gets XML message, parses it, performs requested action (select/insert/update/delete), generates resulting response and sends it back to the Client.
    I use Oracle DB XE 10.2.
    For example: Client sends a request to the server, to append certain Order with new Product info:
    Request:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <Request OrderID="123123123" Action="NewProduct">
    - <Product TempProdID="2" ProdName="L01" VisualID="1" Amount="1" TechClass="1" TechSubject="1" TechVersion="0" TechName="TestTech" ElemOk="0">
    <Modified UserID="XXX" UserGroup="XXX" GroupLevel="0" />
    - <QuickInfo>
    <ProdIcon Format="PNG"
    Encoding="Base64">iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAA
    lC+aJAAAAA3RSTlP////6yOLMAAAAvElEQVR42u3aQQ6EIAwAQP7/afe0
    mo1mBVur0emJgwGmRDFNWwvH9I153OpjyoisefqXW3afm4WypP+MgomvT
    z8AAAAAAAAAAAAAAMAzAClzAWQAdvexfqATEKmA/Fm0rYs5ozvoAWyWj4
    ZqJ9efQKR8BJAHOPEdKAAc/lLdAhC/K68EBG+JWwAixfABgF8Jf6MAAAA
    AAAAAAAAAAAAALwRUGgAAAAAAsgGJ3cfVrcfFl2jiIZzV+V7Zd/8BOtNi
    0MnJ58oAAAAASUVORK5CYII=
    </ProdIcon>
    <Parameters />
    </QuickInfo>
    - <TechProduct CurVer="1" MinVer="1" TotalItems="330" ItemNodeSize="55074">
    - <SubItem Class="TPlGraph" BindID="00B9C004">
    <PropList />
    - <SubItem Ident="Profiles" Class="TProfileList" Child="1" BindID="0188598C">
    <PropList />
    - <SubItem Class="TPlProfile" Child="1" BindID="018CA6CC">
    - <PropList>
    <Property PropIdent="ProfBaze0X" ValText="0" />
    <Property PropIdent="ProfBaze0Y" ValText="990" />
    <Property PropIdent="ProfBaze1X" ValText="990" />
    <Property PropIdent="ProfHier0" ValText="0" />
    - <Property PropIdent="InBorder" ValIdent="None" ValText="N&#279;ra">
    <ExtValue ColIdent="ItemCode" Value="None" />
    <ExtValue ColIdent="Type" Value="" />
    <ExtValue ColIdent="Filter" Value="" />
    <ExtValue ColIdent="Width" Value="0" />
    <ExtValue ColIdent="TechCall" Value="" />
    </Property>
    </PropList>
    </SubItem>
    </SubItem>
    </SubItem>
    </TechProduct>
    </Product>
    </Request>
    I use DOM parsers to parse the received requests, extract certain info and insert it into relational tables using standart SQL queries.
    My question is: what is the best way to store XML data fragments, that are not required to be saved relationally? I need to save the content of node <TechProduct> from the above example to relational table's column. There will be no need to query this column, no need to use relational views. I will use it only when Client application will request to modify certain order's product. Then I will have to send back the same <TechProduct> node via XML response.
    So what column type do I have to use? CLOB? XMLType? Is it better to use object types? Do I have to register XML Schema for better performance? The size of the fragment can be ~2MB.
    Thanks for your help
    Message was edited by:
    Kichas

    Thank you for reply,
    As you suggested, I will use XMLType storage as CLOB (without XML Schema).
    As I mentioned before, I use Java Servlet, deployed on Tomcat WebServer, to receive XML messages from Client application via HTTP POST method.
    I use these libs to get the XML payload and parse it into a Document:
    import org.w3c.dom.*;
    import org.xml.sax.InputSource;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    And here is the code:
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    try {
    // get the XML payload and parse it into a Document
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    Document dom;
    InputSource input = new InputSource(request.getInputStream());
    dom = docBuilder.parse(input);
    catch(Exception ex) {
    System.out.println("Exception thrown in XmlService");
    ex.printStackTrace();
    throw new ServletException(ex);
    I create a relational table, that contains XMLType column:
    CREATE TABLE xwarehouses (
    warehouse_id NUMBER,
    warehouse_spec XMLTYPE)
    XMLTYPE warehouse_spec STORE AS CLOB;
    Now I want to insert all DOM Document into XMLType column. So I do like this:
    import oracle.xdb.XMLType;
    String SQLTEXT = "INSERT INTO XWAREHOUSES (WAREHOUSE_ID, WAREHOUSE_SPEC) VALUES (?, ?)";
    XMLType xml = XMLType.createXML(con,dom);
    PreparedStatement sqlStatement = con.prepareStatement(SQLTEXT);
    sqlStatement.setInt(1,2);
    sqlStatement.setObject(2,xml);
    sqlStatement.execute();
    sqlStatement.close();
    dom is the Document, that I got from HTTP Request input stream.
    My servlet throws an exception:
    java.lang.NoClassDefFoundError: oracle/xml/parser/v2/XMLParseException
    at XmlService.GetMatListServiceHandler.processRequest(GetMatListServiceHandler.java:111)
    at XmlService.XmlServiceHandler.handleRequest(XmlServiceHandler.java:43)
    at XmlService.XmlServiceServlet.doPost(XmlServiceServlet.java:69)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    why does he needs oracle.xml.parser.v2.XMLParseException? I don't use Oracle parser? Does this code line throws the exception (I am not able to debug my code, because I have not configured JDeveloper to be able to use Remote Debuging):
    XMLType xml = XMLType.createXML(con,dom);
    Does it reparses the given dom Document or what?. When I deploy xmlparserv2.jar to Tomcat, everything is ok, application inserts XML data into XMLType column.
    Is there another way to insert the whole org.w3c.dom Document or Document fragment (that is already parsed) into XMLType column. Can you provide any sample code?
    The Document may contain national symbols, so they should be correctly stored and then later retrieved.
    Many thanks.

  • How to store xml files in oracle as xmltype

    public class writexmldb2
         public static void main(String args[]) throws SQLException, FileNotFoundException
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
              Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@172.24.198.131:1521:ncad","scott","tiger");
              OracleXMLSave oracleXMLSave = new OracleXMLSave(conn, "RK1");
              Reader xsltReader=new FileReader(new File("d:/input.xslt"));
              oracleXMLSave.setXSLT(xsltReader, null);
              oracleXMLSave.setRowTag("RK1");
              oracleXMLSave.insertXML(oracleXMLSave.getURL("d:/catalog.xml"));
              OracleXMLQuery query = new OracleXMLQuery(conn, "SELECT JOURNAL_TITLE, PUBLISHER, EDITION, " +"ARTICLE_SECTION, TITLE, AUTHOR FROM JOURNAL");
              Reader xsltReader1=new FileReader(new File("d:/output.xslt"));
              query.setXSLT(xsltReader1, null);
              query.setRowTag("RK1");
              String xmlString=query.getXMLString();
    i wrote this one... but i am getting following errors
    Exception in thread "main" oracle.xml.sql.OracleXMLSQLException: No rows to modify -- the row enclosing tag missing. Specify the correct row enclosing tag.
         at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2385)
         at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2257)
         at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1345)
         at writexmldb2.main(writexmldb2.java:18)

    i also tried with following code. but this one also give some errors.
    import oracle.sql.CLOB;
    import oracle.xml.sql.dml.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import oracle.jdbc.*;
    import java.io.Writer;
    import java.net.*;
    public class xmlwritedb
    public static void main(String args[]) throws SQLException, ClassNotFoundException
    String tabName = "RK1"; // Table into which to insert XML data
    String xmlData = "D:\\catalog.xml"; // XML document filename
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // Initialize a JDBC connection
    Connection conn =
    DriverManager.getConnection("jdbc:oracle:thin:@172.24.198.131:1521:ncad","scott","tiger");
    insertXML( xmlData, conn);
    //OracleXMLSave save = new OracleXMLSave(conn, tabName);
    //System.out.println(" successfully inserted "/*rowCount
    // " rows into "*/+ tabName);
    conn.close();
    public static CLOB getCLOB(String xmlData, Connection conn) throws SQLException{
         CLOB tempClob = null;
         try{
         // If the temporary CLOB has not yet been created, create new
         tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
         // Open the temporary CLOB in readwrite mode to enable writing
         tempClob.open(CLOB.MODE_READWRITE);
         // Get the output stream to write
         Writer tempClobWriter = tempClob.getCharacterOutputStream();
         // Write the data into the temporary CLOB
         tempClobWriter.write(xmlData);
         // Flush and close the stream
         tempClobWriter.flush();
         tempClobWriter.close();
         // Close the temporary CLOB
         tempClob.close();
         } catch(SQLException sqlexp){
         tempClob.freeTemporary();
         sqlexp.printStackTrace();
         } catch(Exception exp){
         tempClob.freeTemporary();
         exp.printStackTrace();
         return tempClob;
    public static void insertXML(String xmlData, Connection conn) {
         CLOB clob = null;
         String query;
         // Initialize statement Object
         PreparedStatement pstmt = null;
         try{
         query = "INSERT INTO RK1 VALUES (XMLType(?))";
         // Get the statement Object
         pstmt = conn.prepareStatement(query);
         // xmlData is the string that contains the XML Data.
         // Get the CLOB object using the getCLOB method.
         clob = getCLOB(xmlData, conn);
         // Bind this CLOB with the prepared Statement
         pstmt.setObject(1, clob);
         // Execute the Prepared Statement
         if (pstmt.executeUpdate () == 1) {
         System.out.println ("Successfully inserted a Purchase Order !");
         } catch(SQLException sqlexp){
         sqlexp.printStackTrace();
         } catch(Exception exp){
         exp.printStackTrace();
    errors;;;;;;;;;
    java.sql.SQLException: ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00210: expected '<' instead of 'D'
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 0
    ORA-06512: at line 1
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
         at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStatement.java:543)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1027)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2885)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:2957)
         at xmlwritedb.insertXML(xmlwritedb.java:70)
         at xmlwritedb.main(xmlwritedb.java:20)

Maybe you are looking for

  • Oracle Database 11.2 Post-Upgrade error: ORA-01658: unable to create INITIA

    Hi, While upgrading of database 11.1.0 to 11.2.0, i am getting the below errors. SQL> @$ORACLE_HOME/rdbms/admin/utlu112s.sql Oracle Database 11.2 Post-Upgrade Status Tool 12-28-2011 23:26:45 Component Status Version HH:MM:SS Oracle Server . VALID 11.

  • Why the FCP 7 is show the different clip view which is not there?

    I am using FCP7 for about 5 years now but never faced this type problem before. I am using footage from 3 different cameras as usual. When I view the clip or export the files it shows the different clips which are not there. Could anyone help me to s

  • Re: Syncing Issue

    Hi, I have a video file in .avi format which I want to burn to a disc but sound and vision are badly out of sync. Any advice on how I correct this will be greatly appreciated. Thank you.

  • Problem text info in the icon wdy alv

    hello friend. i have web dynpro abap, and use the icon in the alv. it is possible change che default info in the icon ?? i use function create_icon, but dont work, dont change my icon... please help me

  • Platform Name

    sql> select platform_name from v$database; Linux IA (32-bit) What's IA in platform name? I hope it's not Itanium ...