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

From Daniel Migowski
Subject Re: Encoding from CopyManager.copyIn()
Date
Msg-id 4A698706.4040502@ikoffice.de
Whole thread Raw
In response to Encoding from CopyManager.copyIn()  (Markus Kickmaier <markus.kickmaier@apus.co.at>)
List pgsql-jdbc
The PrintWriter has another constructor where you can give "UTF8" as
Encoding. Default is platform encoding (usually "Win1252" for me in
Germany).

Best,
Daniel Migowski

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
>
>



pgsql-jdbc by date:

Previous
From: Ondřej Fafejta
Date:
Subject: COPY SELECT with parameters
Next
From: Daniel Migowski
Date:
Subject: Re: Encoding from CopyManager.copyIn()