On 29 October 2011 08:50, James Pharaoh <james@phsys.co.uk> wrote:
> org.hibernate.exception.DataException: could not load an entity:
> [com.pharaohsystems.txt2.db.TextRec#24413864]
> (...)
> Caused by: 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.
> at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getString(AbstractJdbc2ResultSet.java:1891)
> at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getString(AbstractJdbc2ResultSet.java:2190)
> txt2=# select text, encode (text::bytea, 'hex') from text where id = 24413864;
> text | encode
> ------+----------
> 😊 | f09f988a
> (1 row)
> Does anyone have any thoughts on this? I could of course be wrong and
> there could be something else going on here. Any ideas?
Can't reproduce it here; the attached testcase works fine for me
(driver 9.1-901, server 8.4.9):
oliver@flux:~/t$ java -classpath .:postgresql-9.1-901.jdbc4.jar
TestEncoding jdbc:postgresql://localhost:5433/testdb test test
1: \ud83d\ude0a
oliver@flux:~/t$ psql -c "select data, encode(data::bytea, 'hex') from
foo" testdb
data | encode
------+----------
😊 | f09f988a
(1 row)
I've confirmed that the bytes on the wire are indeed F0 9F 98 8A; and
the table has the same contents as your test above.
I assume your database has a UNICODE encoding?
Oliver