Re: Encoding from CopyManager.copyIn() - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Encoding from CopyManager.copyIn()
Date
Msg-id 4A6E8F59.7080004@opencloud.com
Whole thread Raw
In response to Re: Encoding from CopyManager.copyIn()  (Markus Kickmaier <markus.kickmaier@apus.co.at>)
Responses Re: Encoding from CopyManager.copyIn()
List pgsql-jdbc
Markus Kickmaier wrote:
> Thanks for the Responses Daniel and Kris,
>
> but i just don't get it work. I know now what exactly my problem is.
> I have a SQL_ASCCI encoded database. The JDBC driver uses UNICODE as client_encoding. So if i want to copy an
'umlaut'like ü into a table i get the error: invalid byte sequence for UTF8... 
>
> If i test this in pgAdmin it is the same. But if i set client_encoding to 'SQL_ASCII' in pgAdmin it works fine.
> Trying this for my JDBC connection i get a PSQL Exception saying that the client_encoding parameter was changed to
SQL_ASCIIand the JDBC driver just works correctly with UNICODE. 
>
> Any ideas? I'm rather sure it would work if JDBC would let me use SQL_ASCII.

You should convert your database to an appropriate encoding for the data
it contains (perhaps LATIN1?). If the database encoding is SQL_ASCII,
the JDBC driver has no way of knowing how to convert bytes >127 to
Java's UTF-16 String representation.

Basically, SQL_ASCII is only going to work with the JDBC driver if you
only store 7-bit ASCII, or if you happen to be very lucky and have all
clients everywhere use a client_encoding of UNICODE.

-O

pgsql-jdbc by date:

Previous
From: Markus Kickmaier
Date:
Subject: Re: Encoding from CopyManager.copyIn()
Next
From: Markus Kickmaier
Date:
Subject: Re: Encoding from CopyManager.copyIn()