I have a JSON object that I insert into my MySQL DB.
ps = con.prepareStatement("INSERT INTO tableA(a, b, c, d_json)" +
" VALUES(?,?,?,cast(? AS JSON))", Statement.RETURN_GENERATED_KEYS);
// some code
ps.setObject(4, jsonValue);
I insert a hashmap of string as :
Map<String, String> map = new HashMap<String, String>();
map.put("key", "value");
map.put("key1", "value1");
map.put("key2", "value2");
However the json get encoded as following :
'"base64:type15:rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKRvckkACXRocmVz\naG9sZHhwP0AAAAAAAAx3CAAAABAAABnZhbHVlMXQABGtleTJ0AAZ2YWx1ZTJ0\nAANrZXl0AAV2YWx1ZXg="'
I would like to insert a string instead of this. I saw some posts on S.O but I did not find any proper way to fix it. Any help would be appreciated. Thanks !