File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Store Java Object in Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Store Java Object in Database" Watch "Store Java Object in Database" New topic
Author

Store Java Object in Database

Parshuram Walunjkar
Greenhorn

Joined: Jul 25, 2001
Posts: 8
Hi All,
I want to store java Object in oracle database .
My case was like sometime object is Vector type or sometype it is HashMap Type so how can I store that object in database.
Please help me,
Regards and thanks
Parshuram Walunjkar
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I have pretty strong feelings on this, and I believe Objects have no place in a database.
Have a look at this thread where we are looking at Object to Relational mappings.
SJ Adnams
Ranch Hand

Joined: Sep 28, 2001
Posts: 925
depends how long it's gonna be there?
appservers serialize sessions to the database all the time. if your just dumping it in the database for later processing then i guess it's fine just to serialise the object:
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(bos);
os.writeObject(<your type> ;
os.flush();
os.close();
then send bos.toByteArray() to the database.
However, like Dave says it's not a great idea if the data is gonna hang around for more than a software lifecycle. Whats the application?
Simon
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Store Java Object in Database