Postgres UTF-8 clobs with JDBC

旧城冷巷雨未停 提交于 2019-11-30 04:03:40

问题


Postgres JDBC driver seems to not handle UTF-8 clobs correctly. When you retrieve the clob the characters are not correct (you get ? marks for non ascii characters).

Supposedly this is a known issue:

  • http://archives.postgresql.org/pgsql-bugs/2010-09/msg00034.php
  • https://jira.springsource.org/browse/SPR-7520
  • http://archives.postgresql.org/pgsql-jdbc/2011-02/msg00032.php

Luckily for my application I generally avoid clobs so the fields that were clobs I have just made into really big varchars.

How are other people dealing with this limitation?


回答1:


Adding @Type(type="org.hibernate.type.StringClobType") to the clob description in hibernate solves it for me.




回答2:


clob? You mean text or varchar, PostgreSQL doesn't have clob datatype. The PostgreSQL JDBC driver doesn't have problems with that, it would be useless without UTF8 support. It works fine over here.



来源:https://stackoverflow.com/questions/5043992/postgres-utf-8-clobs-with-jdbc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!