• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Insert XML document directly into database

 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic