JDBC寫入postgresql json格式出現以下錯誤:
Caused by: org.postgresql.util.PSQLException: ERROR: column "stu_json" is of type json but expression is of type character varying
建議:You will need to rewrite or cast the expression.
解決方案:
在連接參數中加入:&stringtype=unspecified
用於把JSON類型當STRING類型存儲
或者使用PGobject對象來傳輸
PGobject pgobject = new PGobject();
pgobject.setType("json");
pgobject.setValue(jsonString);