JSONをmySqlに文字列として保存しようとしています。私は、エラーの下に取得しています:JSONをMySQLに保存する
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key, value) values ('SYSTEM_USER', '2017-11-30 13:28:38.512', 'SYSTEM_US' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
コードスニペット:
final Information informationObj = Information.newBuilder().withCreateBy("").withCreatedDate(null)
.withModifiedBy("").withModifiedDate(null).withValue(jsonString).withKey(id).build();
dataRepository.save(informationObj);
値はデシベルでJSONのタイプです。テーブル内のフィールド:
`_id`, `key`, `value`, `created_date`, `created_by`, `modified_by`, `modified_date`
json形式のため、コンマなどの文字が含まれている可能性があります。このjsonをMYSQL DBに保存するソリューションは何ですか? ありがとう、
これはあなたがhttps://dev.mysql.com/doc/refman/5.7/en/json.htmlに役立つことを願っています.jsonデータ型があります – SpringLearner
バグがコード内にあります。しかし、あなたのコードがどのように見えるのかわかりません。 –
Intuition:SQLインジェクションの一種。コードを表示する –