Results 1 to 2 of 2
  1. #1
    Join Date
    May 2007

    Unanswered: SAX: XML Doc to write xml data to database, well I do not know in which p

    I am trying use SAX (java class) and an XML Doc to write xml data to database[mysql or Access], well I do not know in which part of SAX Class, use the database conn, stm and execute query, statements??? can you help? eg startDocument( ), startElement (...), endElement (...) which may have these statements and which non-permitted?

    Also is it required use, ArrayList or Array or a collection to write the data to database?

  2. #2
    Join Date
    Jul 2010
    I have never followed and aproach like that (I dont even know if thats possible using SAX), if you want to read/write an XML that represents a table there are libraries that let you do some data binding between XML and java objects, after that you can persist or read those objects with an ORM (hibernate).

    Eg. You have an XML with 5 persons, transform it to 5 Person java POJOS, persist thouse 5 persons using ORM.

    Inverse mechanism: You query 5 rows from a database, the ORM map them as java Person POJOS, now you transorm that objects to an XML.

    Tools that can be helpful to do the XML-object data binding:

    Converting between Java objects and XML with Quick
    JiBX: Binding XML to Java Code
    XStream - About XStream
    There are a lot more....

    My question is, you really need that? why not write the XML and store it in a column of your table. If you are using mysql you can use a TEXT or BLOB column, if you are using SQL Server you can use an XML column. (If you use an XML column you can Query the table and Xquery directly the XML in one step!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts