Cannot select Unicode data from PostgreSQL with LIKE
I have a PostgreSQL database with some Unicode values. For example "vaishali" in Marathi. I want to fire a query SELECT * FROM table WHERE name LIKE vaishali
(I type "vaishali" in Marathi, 开发者_开发技巧so I first convert to unicode in my prog). But it matches nothing. Why?
There are two possible causes for this problem:
The JDBC driver is not instructed to use UTF-8. This would actually be a bug, because it's supposed to automatically pickup the correct character encoding from the DB metadata. To my experience, the PostgreSQL JDBC drivers have always done a good job in this.
The SQL query is actually wrongly constructed/formulated. The one which you've posted is already syntactically invalid. Please post the actual code and query. Also, you seem to insist that it only happens with a
LIKE
query. How about a normalWHERE name = 'foo'
query?
精彩评论