XML/Java Help


XML & Web services: XML/Java Help

  1. XML/Java Help (4 messages)

    We need to develop a Java application that will read the around 5000 records from a oracle database and write them XML file (size around 5 MB). We have following architecture in mind.

    1. This application will read a xml configuration file which will contain all the configuration related information and queries to be executed.
    2. Application will parse, validate this XML and extract all the queries to build query objects.
    3. These query objects will execute the queries and build a DOM tree in the memory.
    4. This DOM tree object will be written to the hard disk as a XML file.

    Please let us know if any performance and memory issues in this.


    Threaded Messages (4)

  2. XML/Java Help[ Go to top ]

    If the 5000 records you mentioned are all of the same "type" (and there isn't a tree-like hierarchy present), I would suggest avoiding DOM.

    If you are able to do something like this...

    write XML header
    for all records in resultset {
        write record in XML format
    write XML footer

    ...you'll avoid keeping the 5 meg chunk in memory (actually could be more than 5 megs), which is quite a relief for the hardware.
  3. XML/Java Help[ Go to top ]

    If you have an option, I suggest you use SAX rather than DOM. SQL query results are streamed to you, and there's no need to create a bottle-neck that will stop the stream-lined process. If you just write the result as you get them, your performance and memory footprint will be much better.

  4. XML/Java Help[ Go to top ]

    Also be careful at String operations if you need to do.
  5. XML/Java Help[ Go to top ]

    Only if you can use Oracle specific solution, try to use the XML features inside Oracle Database. For Example, if you just need to return the result set in XML format, why not call a Stored Procedure(PL/SQL) that returns the resultset in XML in a CLOB object. Packages are available in PL/SQL that construct xml file from a SQL query. Again,this is not an option if you are looking for vendor-neutral solution.