在SQL数据库中存储HashMap [英] Storing a HashMap in an SQL database
问题描述
你如何在SQL数据库中存储HashMap?另外,如何将SQL数据库中的HashMap加载回HashMap的实例?
好的,这就是我正在做的。我有一个数据库来存储我的游戏的玩家数据。它有一张包含他们的用户名和密码的表格。每个玩家都有一个存储其属性的HashMap。我需要将HashMap存储在数据库以及它的用户。
用户,
键,
值
然后看起来像
user 1,property1,value1
user 1,property2,value2
<用户2>,property1,value1
user 3,property1,value1
user 3,property2,value2
然后,您只需将数据读回并在用户字段四周重新构建每个有表的表格。
How do you store a HashMap inside of an SQL database? Also, how would you load that HashMap from a SQL database back into an instance of a HashMap?
Okay, this is what I'm doing. I have a database to store the player data for my game. It has a table containing their usernames and passwords. Each player has a HashMap that stores their properties. I need to store that HashMap in the database along with it's respective user.
You need a 3 column table
user,
key,
value
Would then look like
"user 1", "property1", "value1"
"user 1", "property2", "value2"
"user 2", "property1", "value1"
"user 3", "property1", "value1"
"user 3", "property2", "value2"
You would then just read the data back in and look round the user field to rebuild each has table.
这篇关于在SQL数据库中存储HashMap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!