Skip site navigation (1) Skip section navigation (2)

Re: Encoding from CopyManager.copyIn()

From: Daniel Migowski <dmigowski(at)ikoffice(dot)de>
To: Markus Kickmaier <markus(dot)kickmaier(at)apus(dot)co(dot)at>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Encoding from CopyManager.copyIn()
Date: 2009-07-24 10:07:16
Message-ID: 4A6987D4.2080406@ikoffice.de (view raw or flat)
Thread:
Lists: pgsql-jdbc
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
>
>   



In response to

pgsql-jdbc by date

Next:From: Kris JurkaDate: 2009-07-24 15:22:32
Subject: Re: SSL - NonValidatingFactory
Previous:From: Daniel MigowskiDate: 2009-07-24 10:03:50
Subject: Re: Encoding from CopyManager.copyIn()

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group