This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML convertion to java.sql.Clob

 
Mathangi Shankar
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13047
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Output to a StringWriter instead of a File - use the resulting String method toCharArray() to get a char[]
Bill
 
Mathangi Shankar
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

Mathangi.
 
Kumar Bisk
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13047
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic