Re: Encoding from CopyManager.copyIn()

From: Markus Kickmaier <markus(dot)kickmaier(at)apus(dot)co(dot)at>
To: Daniel Migowski <dmigowski(at)ikoffice(dot)de>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Encoding from CopyManager.copyIn()
Date: 2009-07-27 08:23:47
Message-ID: 5637857.99741248683027131.JavaMail.root@donald.apus.co.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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.

BR, Markus

----- "Daniel Migowski" <dmigowski(at)ikoffice(dot)de> schrieb:

> Or, in your case you have to wrap the OutputStream in an
> OutputStreamWriter (which has the encoding parameter in the
> constructor).
>
> best
> Daniel
>
> Markus Kickmaier schrieb:
> > Hello,
> >
> > I'm using the copyIn() function of the CopyManager. It works fine
> until I don't use an "umlaut" like ü. Then i get an PSQLException:
> >
> > org.postgresql.util.PSQLException: ERROR: invalid byte sequence for
> encoding "UTF8": 0xfc
> >
> > My code looks like follows:
> >
> > ByteArrayOutputStream output = new ByteArrayOutputStream();
> > PrintWriter writer = new PrintWriter(output);
> > writer.println("abcüäö");
> > writer.flush();
> > ByteArrayInputStream input = new
> ByteArrayInputStream(output.toByteArray());
> > long result = ((PGConnection) con_).getCopyAPI().copyIn(statement,
> input);
> >
> > After searching at google i found out that this is an encoding
> problem. The database doesn't know what charset I'm using.
> >
> > Any suggestion how i can specify the encoding i want to use?
> >
> > BR, Markus
> >
> >

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Clemens Eisserer 2009-07-27 08:36:16 Re: Updateable ResultSet doesn't fetch sequence-generated values
Previous Message Albe Laurenz 2009-07-27 08:04:01 Re: No suitable driver found