Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 4CE68634F55 for ; Wed, 22 Jul 2009 16:52:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 23755-02-6 for ; Wed, 22 Jul 2009 16:51:59 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail.postgresql.org (Postfix) with ESMTP id EB1C7635ED5 for ; Wed, 22 Jul 2009 16:41:11 -0300 (ADT) Received: by leary.csoft.net (Postfix, from userid 1112) id 4F1EFA2CE; Wed, 22 Jul 2009 15:41:10 -0400 (EDT) Date: Wed, 22 Jul 2009 15:41:10 -0400 (EDT) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Markus Kickmaier cc: pgsql-jdbc@postgresql.org Subject: Re: Encoding from CopyManager.copyIn() In-Reply-To: <9709844.92821248280225595.JavaMail.root@donald.apus.co.at> Message-ID: References: <9709844.92821248280225595.JavaMail.root@donald.apus.co.at> User-Agent: Alpine 2.00 (BSO 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.026 tagged_above=-10 required=5 tests=AWL=0.026 X-Spam-Level: X-Archive-Number: 200907/54 X-Sequence-Number: 19822 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