From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
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-22 19:41:10 |
Message-ID: | alpine.BSO.2.00.0907221538320.17424@leary.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
On Wed, 22 Jul 2009, Markus Kickmaier wrote:
> 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);
You should be using the copyIn(String, Reader) function rather than
InputStream. That way the CopyManager can encode the provide data to
the database in the encoding it requires.
If using the InputStream method, you need to provide the data in UTF-8
encoding.
Kris Jurka
From | Date | Subject | |
---|---|---|---|
Next Message | Ondřej Fafejta | 2009-07-23 08:49:12 | COPY SELECT with parameters |
Previous Message | Markus Kickmaier | 2009-07-22 16:30:25 | Encoding from CopyManager.copyIn() |