This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes How to store StringBuffer contents into a blob? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to store StringBuffer contents into a blob?" Watch "How to store StringBuffer contents into a blob?" New topic
Author

How to store StringBuffer contents into a blob?

Abhi Basu
Greenhorn

Joined: Apr 05, 2004
Posts: 13
I want to store the blob into a db table after this is accomplished.

Thanks!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

Abhi,
The StringBuffer can be converted into a string which can be converted into a blob. The constructor for the blob is database specific.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Abhi Basu
Greenhorn

Joined: Apr 05, 2004
Posts: 13
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to store StringBuffer contents into a blob?
 
Similar Threads
inserting images into an oracle database
XML, flat files to database
problem in storing an object to the database!
how to insert a picture in database
Inserting image at database