aspose file tools*
The moose likes XML and Related Technologies and the fly likes Insert XML document directly into database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Insert XML document directly into database" Watch "Insert XML document directly into database" New topic
Author

Insert XML document directly into database

Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
Hi,

I have created a XML document using JDOM and is printing the document out in the browser on the fly. See the code below.

Now I want to change the code, so it inserts the XML document into the database as a blob without storing the file on the server. How is that possible?

I need somehow to convert the Document to a binaryStream, but how can I do that?



[ November 02, 2006: Message edited by: Jeppe Fjord ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

Have your XMLOutputter write to a ByteArrayOutputStream (by the way, it's always a better policy to write XML to an OutputStream rather than a Writer, unless you take the trouble to make your Writer have the same encoding as the XML, which you didn't). Then get the byte array from that. Then create a ByteArrayInputStream from that byte array. You know what to do from here on.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Insert XML document directly into database