pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kalle Hallivuori <kato@iki.fi>
To: ttvvaa <ttvvaa@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: JDBC COPY error encoding
Date: Tue, 21 Aug 2007 18:21:21 +0300
Message-ID: <c637d8bb0708210821q14d0d8cgc354101ea2fb53aa@mail.gmail.com> (raw)
In-Reply-To: <12236825.post@talk.nabble.com>
References: <12236825.post@talk.nabble.com>

Hi!

2007/8/20, ttvvaa <ttvvaa@gmail.com>:
> I use PostgreSQL 8.2 for WinXP (SP2).
> I try to use "postgresql-jdbc-8.2-505-copy-20070719.jdbc3.jar"
> (from http://kato.iki.fi/sw/db/postgresql/jdbc/copy/):
>
>            FileInputStream fs = new FileInputStream("D://t.txt");
>            ((PGConnection)con).getCopyAPI().copyIntoDB("COPY table1 FROM
> STDIN", fs);
>            fs.close();
>
> but have error: 'org.postgresql.util.PSQLException: ERROR: invalid byte
> sequence for encoding "UTF8": 0xa0'.
>
> file 'D://t.txt' used WIN866 encoding.
> DB used UTF8 encoding.
>
> Command successfully runs in psql-console:
>       set client_encoding to WIN866;
>       copy table1(nn) from 'd://t.txt';
>
> How can I solve this problem?

JDBC copy does not know the encoding in the provided bytestream. Thus
you have to convert the data to encoding used by server by yourself,
before feeding it to copy.

-- 
Kalle Hallivuori +358-41-5053073 http://korpiq.iki.fi/



view thread (3+ messages)  latest in thread

Message-ID: <c637d8bb0708210821q14d0d8cgc354101ea2fb53aa@mail.gmail.com>
Permalink:  ../c637d8bb0708210821q14d0d8cgc354101ea2fb53aa@mail.gmail.com/
Also on:    postgresql.org/message-id/c637d8bb0708210821q14d0d8cgc354101ea2fb53aa@mail.gmail.com

 · 

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: kato@iki.fi, ttvvaa@gmail.com
  Subject: Re: JDBC COPY error encoding
  In-Reply-To: <c637d8bb0708210821q14d0d8cgc354101ea2fb53aa@mail.gmail.com>
  References: <12236825.post@talk.nabble.com> <c637d8bb0708210821q14d0d8cgc354101ea2fb53aa@mail.gmail.com>

* 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