想要将对象存储在MySQL数据库中 [英] Want to store Object in MySQL database

查看:1127
本文介绍了想要将对象存储在MySQL数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆