File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Saving XML document in DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Saving XML document in DB" Watch "Saving XML document in DB" New topic
Author

Saving XML document in DB

Andrew McLaren
Ranch Hand

Joined: May 27, 2005
Posts: 33
I am looking to save an XML document - really a DOM, not an actual file - in a SQL Server database. I've done lots of rummaging, and managed only to confuse myself (which doesn't take much). Any gentle, or not so gentle, nudges in the right direction would be greatly appreciated.

The closest I've been able to get is to convert the DOM to a string, and then write pass that thru a StringReader, and then finally insert it into the table, in an NText column, with .setCharacterStream. That gets some of the text from the DOM in, but not even close to all of it.

Thanks
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    5

You need to save it as a Blob/Clob. Some databases like Oracle actually support XML as a datatype, although its really just a fancy Blob/Clob.


My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Saving XML document in DB
 
Similar Threads
How to append an element in XML document
Problem in writing DOM Object with PI
WA #1.....word association
Memory Limitation using XML Data Binding
convert javaobjects to xml and xml to java objects dynamically