pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Markus Kickmaier <markus.kickmaier@apus.co.at>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Encoding from CopyManager.copyIn()
Date: Wed, 22 Jul 2009 15:41:10 -0400 (EDT)
Message-ID: <alpine.BSO.2.00.0907221538320.17424@leary.csoft.net> (raw)
In-Reply-To: <9709844.92821248280225595.JavaMail.root@donald.apus.co.at>
References: <9709844.92821248280225595.JavaMail.root@donald.apus.co.at>



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




view thread (7+ messages)  latest in thread

Message-ID: <alpine.BSO.2.00.0907221538320.17424@leary.csoft.net>
Permalink:  ../alpine.BSO.2.00.0907221538320.17424@leary.csoft.net/
Also on:    postgresql.org/message-id/alpine.BSO.2.00.0907221538320.17424@leary.csoft.net

 · 

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: books@ejurka.com, markus.kickmaier@apus.co.at
  Subject: Re: Encoding from CopyManager.copyIn()
  In-Reply-To: <alpine.BSO.2.00.0907221538320.17424@leary.csoft.net>
  References: <9709844.92821248280225595.JavaMail.root@donald.apus.co.at> <alpine.BSO.2.00.0907221538320.17424@leary.csoft.net>

* 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