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 JDBC and the fly likes Storing a Java Object in Oracle [code] Blob [/code] 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 » Databases » JDBC
Bookmark "Storing a Java Object in Oracle [code] Blob [/code]" Watch "Storing a Java Object in Oracle [code] Blob [/code]" New topic
Author

Storing a Java Object in Oracle [code] Blob [/code]

Sri Ram
Greenhorn

Joined: Feb 13, 2006
Posts: 20
Can you tell me how to store and Retrieve a Java Object using a Oracle ???


Sriram<br />SCJP<br />SCWCD
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Typically, you might serialise to a ByteArrayOutputStream then write the byte array to the BLOB. To read, get the byte array from the BLOB then deserialise from a ByteArrayInputStream based on that array.

If you don't know how to serialise/deserialise to/from streams, read up on Java Serialisation, independent of databases.

As a possible optimisation, note that Blob objects have built-in InputStream and OutputStream functionality, from Java 1.4 onwards.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Original Poster sent me a private message asking for code for this. UseTheForumNotEmail

No need for me to go writing example code. Sun's own ought to suffice. See Sun's BLOB example code.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

Peter,
Thanks for bringing it back to the forums!


[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
 
 
subject: Storing a Java Object in Oracle [code] Blob [/code]
 
Similar Threads
inserting images into an oracle database
BLOB data type
Oracle function using Java to return Blob is zero size
java.io.ioException
Create BLOB Object