If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > SAX: XML Doc to write xml data to database, well I do not know in which p

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-10-10, 01:43
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 139
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?
Reply With Quote
  #2 (permalink)  
Old 07-21-10, 02:49
rsansores rsansores is offline
Registered User
 
Join Date: Jul 2010
Posts: 5
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!)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On