Re: JDBC COPY error encoding

From: "Kalle Hallivuori" <kato(at)iki(dot)fi>
To: ttvvaa <ttvvaa(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JDBC COPY error encoding
Date: 2007-08-21 15:21:21
Message-ID: c637d8bb0708210821q14d0d8cgc354101ea2fb53aa@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi!

2007/8/20, ttvvaa <ttvvaa(at)gmail(dot)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/

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message ttvvaa 2007-08-21 19:38:48 Re: JDBC COPY error encoding
Previous Message David Goodenough 2007-08-21 14:06:20 Support for ResultSetMetaData.getTableName