Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id B59B5634C8D for ; Tue, 28 Jul 2009 02:41:07 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 12895-04 for ; Tue, 28 Jul 2009 05:40:57 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tremor.opencloud.co.nz (tremor.opencloud.co.nz [131.203.101.230]) by mail.postgresql.org (Postfix) with ESMTP id E03BF634C89 for ; Tue, 28 Jul 2009 02:40:56 -0300 (ADT) Received: from 219-89-36-132.dialup.xtra.co.nz ([219.89.36.132] helo=[192.168.1.3]) by tremor.opencloud.co.nz with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1MVfQa-0005x6-FU; Tue, 28 Jul 2009 17:40:44 +1200 Message-ID: <4A6E8F59.7080004@opencloud.com> Date: Tue, 28 Jul 2009 17:40:41 +1200 From: Oliver Jowett User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: Markus Kickmaier CC: Daniel Migowski , pgsql-jdbc@postgresql.org Subject: Re: Encoding from CopyManager.copyIn() References: <5637857.99741248683027131.JavaMail.root@donald.apus.co.at> In-Reply-To: <5637857.99741248683027131.JavaMail.root@donald.apus.co.at> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=-10 required=5 tests=none X-Spam-Level: X-Archive-Number: 200907/77 X-Sequence-Number: 19845 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_ASCII and 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