Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Store Object in Database

 
kandarp mehta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I store field value which return type is Object in MySQL? I mean that I want to store below field value in MySQL through JDBC. Is anybody knows equivalent datatype in MySQL?
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If you want to a Java object as a serialized stream in java serialization format, then store it as a BLOB in the database.

But this is rather unusual, since it ties that column to java. If your database is, or may potentially be, used from another platform (like PHP), then store the object fields separately, mapping them meaningfully to regular SQL types.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4028
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no such thing as an object data type in a database. You could serialize the data as a string but I wouldn't recommend it since then searching or querying the object would be useless. Better to break the object up into meaningful, structured data.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50225
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic