This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XML convertion to java.sql.Clob 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 » Engineering » XML and Related Technologies
Bookmark "XML convertion to java.sql.Clob" Watch "XML convertion to java.sql.Clob" New topic
Author

XML convertion to java.sql.Clob

Mathangi Shankar
Ranch Hand

Joined: Nov 01, 2004
Posts: 56
Hi,

I have an XML file in a Document object. I need to store this object as a CLOB object into memory.

The XML which I have created need not be in a Document object I can create through StringBuffer too.

The main thing is to convert to Clob object.

How should I achieve this?

I have tried in various procedures? But failed.

Can anybody help me out?

It would be great if I get the solution immediately.


--------------------------------<br />SCJP1.4
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
Output to a StringWriter instead of a File - use the resulting String method toCharArray() to get a char[]
Bill
Mathangi Shankar
Ranch Hand

Joined: Nov 01, 2004
Posts: 56
Hi,

Can you please eloborate on what you had mentioned? It would be helpful to me.

Mathangi.
Kumar Bisk
Ranch Hand

Joined: Mar 18, 2003
Posts: 31
Just let me know. Can you able to store a string/file/stringbuffer as a clob? Then storing a Document is quite straigt forward.
Looki into PreparedStatement setCLob() method. I am using this method extensively to store large amount of XML data.

regards,
Ranjan
ranjanbaisak at yahooo dot com
Mathangi Shankar
Ranch Hand

Joined: Nov 01, 2004
Posts: 56
Hi,

I was able to do it. That is from stringbuffer to a clob.

In the setClob method of PreparedStatement for the clob object can we
pass the document object directly.

Will that work?

Please let me know.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
Since java.sql.Clob does not have a method for dealing with XML Document objects, it appears to me that you will have to transform the Document to a stream of characters, or otherwise convert it to a String to use one of the Clob methods.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18114
    
    8

shachindra singh,
Your post was moved to a new topic.
This is a question about CLOB, not XML.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML convertion to java.sql.Clob
 
Similar Threads
Document object into Database
Urgent help needed ! [Oracle CLOB, BLOB & XML9
Reading objects
How to convert a java.sql.CLOB object to String
How to Convert a java.sql.CLOB object to String