想要将对象存储在MySQL数据库中 [英] Want to store Object in MySQL database
问题描述
我在java中有一个变量,其返回类型为Object(java.lang.Object).我想将此变量值存储在MySQL数据库中而不强制转换为其他任何原始数据类型. MySQL中是否有与对象相关的任何数据类型?
I have a variable in java which return type is Object(java.lang.Object). I want to store this variable value in MySQL database without casting in any other primitive data type. Is there any data type available in MySQL related to Object?
推荐答案
您可以使用BLOB
存储原始数据,但是否则,MySQL没有专门用于Java对象的数据类型.
You can use a BLOB
to store the raw data, but otherwise no, MySQL does not have a datatype specifically for a java object.
作为旁注:您可能不应该将原始对象存储到数据库中,这种情况会阻止您对数据库执行任何类型的查询.
As a side note: You probably shouldn't be storing a raw object into the database, that kind of prevents you from doing any sort of queries on it.
这篇关于想要将对象存储在MySQL数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!