This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
How to persist a Java object into a database that doesn't support Object persistance? One way which comes to my mind is to serialize a Java object to a file and then store that file as a BLOB type in the database. Is it possible to avoid serializing the object to a file before storing it into the database. I mean, can we somehow straight away serialize the object to the database instead of serializing it to the file system? Or, are there any better alternative for this? Note: I'm not sure whether this post belongs to this forum or to the IO & Streams forum. If you (the Moderators) think otherwise, please move it to the IO forum. [ January 30, 2004: Message edited by: Mani Ram ]
Mani, You could write to an ObjectOutputStream rather than a physical file. Or you could use a toString() type method and call getBytes() on the result. Either of these should give you an array of bytes that you can persist as a BLOB.