Link to home
Start Free TrialLog in
Avatar of arjoshi77
arjoshi77

asked on

xml jdom and database

hello:

I am in need of the following functionality.

I would like to create a JDOM xml document and store it in mysql as a "TEXT".
Alternatively I would like to pull the "TEXT" from MySQL and parse it into a JDOM DOcument.
I tried to google but could not find a satisfactory answer.
if you could let me know the JDOM API calls to articulate the above scenario I would appreciate it very much
Thanks
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

using below link you will know on how to store xml data .

http://www.roseindia.net/servlets/login-Xml-servlet.shtml

using below link you will know on how to  write an XML document, using JDOM

http://www.java2s.com/Code/Java/XML/MakeupandwriteanXMLdocumentusingJDOM.htm
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
By the way this is the veriosn of JDOM which I used:

http://www.jdom.org/dist/binary/jdom-1.1.2.zip

and jar file jdom-1.1.2.jar form build folder
after you unzip

And this is exmaple inserting CLOB data into MySQL database:

http://www.roseindia.net/tutorial/java/jdbc/insertclob.html
Avatar of CEHJ
Try the following
XMLOutputter out = new XMLOutputter();
StringWriter sw = new StringWriter();
out.output(document, sw);
PreparedStatement ps = connection.prepareStatement("insert into mytable(xml_column) values (?)");
ps.setString(1, sw.toString());
ps.executeUpdate();
// close db stuff

Open in new window