Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to store StringBuffer contents into a blob?

 
Abhi Basu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to store the blob into a db table after this is accomplished.

Thanks!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhi,
The StringBuffer can be converted into a string which can be converted into a blob. The constructor for the blob is database specific.
 
Abhi Basu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sbFinal is the StringBuffer with all the data.

BLOB oracleBlob = null;
OutputStream outstream = ((BLOB)oracleBlob).getBinaryOutputStream();
byte[] data = sbFinal.toString().getBytes();
outstream.write(data);
outstream.close();

Is this how to do it for an Oracle blob? Thanks.
[ May 21, 2004: Message edited by: Abhi Basu ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic