• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

why serialization

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai to all Ranchers,

"Serialization is writing the state of java object into a file system" but i have one doubt that is why we have to use file system to store object state by using Serialization why not in database( means SQL Db or some other)

Thank you
 
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please QuoteYourSources. Who said you have to use the file system? You get a byte stream and can do with that whatever you want.

But as you get only a byte stream that doesn't make sense to anyone else than a Java VM, storing this in a SQL db typically is not very useful. Sure, you can store it in a blob field, but you loose all the structured approaches that SQL is providing.
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think one point needs to made clearer: serialization in Java can take different forms. The binary approach (using Object[In|Out]putStream) hands you a byte[] array that is usable only by JVMs, as Hauke said. What's more, this approach is not guaranteed to work across JVM versions - good luck getting an object serialized with Java 6 b10 to work with a Java 6 b20 JVM, much less between Java 5 and Java 6 JVMs.

But other approaches exists; for example, if an object conforms to JavaBean standards, then the java.beans.XMLEncoder/XMLDecoder classes create an XML representation that is guaranteed to work across JVM versions, is amenable to XML processing, and is searchable when stored in a file system or DB.
 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Back in Java 1.0, when the most popular usage of the language was for applets, serialization was mostly about transferring the data in an object instance between the browser and the server. And we were writing our own, there was no support for this provided in the language. But I think it's clear whoever said "file system" just wasn't thinking broadly enough.
 
get schwifty. tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic