Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes JDBC and Relational Databases and the fly likes Saving an XML to DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Saving an XML to DB" Watch "Saving an XML to DB" New topic
Author

Saving an XML to DB

surya naidu
Ranch Hand

Joined: Jul 26, 2010
Posts: 32
hi everyone

I have a formfile object which has an XML which is uploaded from the UI
I need to save this in to a DB
Can anyone suggest the best way to do this
The XML is going to be very huge,And we also dont have a table structure(like a bean) which can hold this

Please suggest
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19947
    
  24

You should use a CLOB field for this. The name for the field type may differ though; MS SQL Server calls it "text" (or "ntext for Unicode) for instance.
After that you use PreparedStatement with setCharacterStream / setClob (or setNCharacterStream / setNClob for Unicode text fields). You can use a StringReader to convert a String into a Reader if necessary.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Saving an XML to DB