org.postgresql.util.PSQLException: Invalid character data was found.

org.postgresql.util.PSQLException: Invalid character data was found.,第1张

org.postgresql.util.PSQLException: Invalid character data was found.

java代码查询postgresql数据库出现报错如下:

org.postgresql.util.PSQLException: Invalid character data was found. This is most likely caused by stored data containing characters that are invalid for the character set the database was created in. The most common example of this is storing 8bit data in a SQL_ASCII database.

尝试修改连接postgresql客户端编码,未能解决问题。

对于存在乱码字段进行base64编码,可正常查询日志,查询结果后利用java对base64进行解码即可:

encode(vdata::bytea,'base64') as vdata //postgresql字段base64编码函数。

上述方法只能解决部分乱码造成的问题,并不能完全兼容乱码问题,暂未找到办法彻底解决,临时可通过sql语句根据一定的逻辑,过滤掉乱码数据。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5716120.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-18

发表评论

登录后才能评论

评论列表(0条)

保存