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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
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
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