Two Laptop Bag
The moose likes XML and Related Technologies and the fly likes Storing as CLOB data in the database..... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "Storing as CLOB data in the database....." Watch "Storing as CLOB data in the database....." New topic
Author

Storing as CLOB data in the database.....

Mandy S Smith
Greenhorn

Joined: Jan 20, 2002
Posts: 24
I have marshalled the xml data into an outputStream, now how do i read the data from the outputstream and store that data as CLOB object in the database? I am using oracle database.
Could anyone help me on this.
Appreciate your response !
Thanks.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12271
    
    1
Doesn't the java.sql.Clob interface have a setCharacterStream() to get a Writer and setAsciiStream() to get an OuputStream?
Bill
Navjeet Nehra
Greenhorn

Joined: Sep 18, 2003
Posts: 13
Hi,
The code below uses the getCharacterOutputStream() to get the writer. Hope it helps
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Clob clob = null;

// writing the message into the Clob Object.
Writer wr =
((weblogic.jdbc.vendor.oracle.OracleThinClob) clob).getCharacterOutputStream();
char[] b = message.toCharArray();
wr.write(b);
wr.flush();
String updateClobQuery = "UPDATE {Table} SET CLOB_MESSAGE = ? " +
"WHERE TIME_STAMP_LOG = ?";

preparedStatement = conn.prepareStatement(updateClobQuery);
preparedStatement.setClob(1, clob);
preparedStatement.setString(2, timeStamp);
preparedStatement.execute();
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Storing as CLOB data in the database.....
 
Similar Threads
how to download a zip file from database?
How to read/write text file to db2 by using java code
Storing large String in CLOB
Question on update CLOB column when the column value is null
BLOB