pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Markus Kickmaier <markus.kickmaier@apus.co.at>
Cc: Daniel Migowski <dmigowski@ikoffice.de>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Encoding from CopyManager.copyIn()
Date: Tue, 28 Jul 2009 17:40:41 +1200
Message-ID: <4A6E8F59.7080004@opencloud.com> (raw)
In-Reply-To: <5637857.99741248683027131.JavaMail.root@donald.apus.co.at>
References: <5637857.99741248683027131.JavaMail.root@donald.apus.co.at>

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



view thread (7+ messages)  latest in thread

Message-ID: <4A6E8F59.7080004@opencloud.com>
Permalink:  ../4A6E8F59.7080004@opencloud.com/
Also on:    postgresql.org/message-id/4A6E8F59.7080004@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, markus.kickmaier@apus.co.at, dmigowski@ikoffice.de
  Subject: Re: Encoding from CopyManager.copyIn()
  In-Reply-To: <4A6E8F59.7080004@opencloud.com>
  References: <5637857.99741248683027131.JavaMail.root@donald.apus.co.at> <4A6E8F59.7080004@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox