File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Persisting a Java Object

 
Mani Ram
Ranch Hand
Posts: 1140
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mani, you may want to visit the (fairly new) Object Relational Mapping Forum.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic