• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in Serialization  RSS feed

 
Vijay Kumar
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi..
I just want to know how to save the seriliazed object in database..
I am able to save in a text file & can reterive it.....
please help me out...
Thanks
Vijay
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, if you're serializing to a file, it's almost certainly not a text file. Unless by "serialization" you mean certain nonstandard forms with comparable functionality, such as XStream. (Which generates nice pretty XML files which definitely qualify as readable text.) Anyway though, standard Java serialization results in binary files, not text. If you want to put a serialized object into a database rather than a file, you probably want to use a BLOB datatype. Java's Blob interface allows you to setBinaryStream() - just write the serialized bytes to the OutputStream, and execute the associated Statement. Most of the remaining details deal with how to use any database in Java - I'd go to the JDBC forum for further details in this area.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!