Want to save an object in a MySQL database

I have a variable in java whose return type is Object (java.lang.Object). I want to store this value of a variable in a MySQL database without using any other primitive data types. Is there any data type available in MySQL related to Object?

+5
source share
3 answers

You can use it BLOBto store raw data, but otherwise, MySQL does not have a specific data type for a java object.

As a side note. You probably should not store the raw object in the database, which prevents you from making any queries on it.

+5

, XML JSON. , . Xstream, . , /.

, , Bean/POJO.

+3

BLOB could do this. Serialize the object into an array of bytes, and INSERT as a BLOB.

+2
source

All Articles