在 java 中从 db 获取结果时将结果集存储在数组中?

Storing the result set in array while fetching from db in java?

这是我从 db 中的列名称中得到的

                          data
                  CLONE,CREATE,DELETE

我想在数组中存储类似这样的东西

                    [CLONE,CREATE,DELETE]

这就是我正在尝试的,但输出是正常的 JSON 像这样

"clone ,create ,delete"

我的代码是这样的

        JSONObject jsonObject = new JSONObject();
            JSONArray array = new JSONArray();
            ResultSet rs = RetrieveData();
            while (rs.next()) {
                JSONObject record = new JSONObject();
                record.put("permissionType", rs.getString("data"));
                array.put(record);
            }
            jsonObject.put("JSON_OBJECT", array);
            try {
                System.out.println(jsonObject);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

我认为您需要考虑做类似 rs.getString("data").split(",") 的事情,它将 return 字符串数组使用逗号拆分,即 ["clone", "create", "delete"]