aspose file tools*
The moose likes JDBC and the fly likes Is there any way I can store an object to database in one cell Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Is there any way I can store an object to database in one cell" Watch "Is there any way I can store an object to database in one cell" New topic
Author

Is there any way I can store an object to database in one cell

T Zaman
Greenhorn

Joined: Oct 31, 2005
Posts: 18
Hi ,
I would like to store an object(such as a list) to a database table in a single cell. What I want to do is store the object in a cell , I want to update the state of the object if I want to later on.Is this possible ? Any idea or suggestion will be highly appreciated . Thanks a lot in advance


SCJP 5.0 SCWCD 5.0
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19692
    
  20

You can use a BLOB and then serialize the object to the field. Updating will then be deserializing, updating, reserializing.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Pana Ion
Greenhorn

Joined: May 03, 2010
Posts: 3
imo serialize/deserialize is not a really good idea if the classes of the objects in the lists may change at any point in the future- you will may get an exception when deserializing the older serialized version. This may even be true for different jdk versions. I think "serializing" with a more general format (in a BLOB) - e.g. XML would be better - as you could control backward compatibility. of course, it involves more work.

Of course, what I said is true only if you intend to store objects as data (if you store a class that is a business rule or some sort of handler i guess it is ok).
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

Yes, but it's probably not a good idea. Figure out the important elements of an object and create columns (or normalized tables) based on those elements. You'll gain the ability to query and run reports on the data once its structured in the database.


My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there any way I can store an object to database in one cell