• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doesn't the java.sql.Clob interface have a setCharacterStream() to get a Writer and setAsciiStream() to get an OuputStream?
Bill
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
reply
    Bookmark Topic Watch Topic
  • New Topic