aspose file tools*
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
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: 30537
    
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
 
Consider Paul's rocket mass heater.
 
subject: Storing a Java Object in Oracle [code] Blob [/code]