Skip site navigation (1) Skip section navigation (2)

Re: COPY Command UtfToLocal: could not convert UTF-8

From: Kris Jurka <books(at)ejurka(dot)com>
To: kerdem <kerdem(at)focusmr(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: COPY Command UtfToLocal: could not convert UTF-8
Date: 2004-03-14 03:16:41
Message-ID: Pine.BSO.4.56.0403132209260.491@leary.csoft.net (view raw or flat)
Thread:
Lists: pgsql-jdbc

On Wed, 10 Mar 2004, kerdem wrote:

> I installed PG 7.3.4 and created DB with encoding LATIN10  . I tried
> to import Flat-File  with Copy Command 
> 
> String  delimeter ;";
> String  FILEPATH ="/home/kerdem/upstream/LIQ.txt";
> String pgcopy ="copy public.liq_import from '"+FILEPATH+"' with
> delimiter '"+delimeter+"'  NULL AS '' "; 
> 
>          pstmt = con.prepareStatement(pgcopy); 
>                         pstmt.executeUpdate();  
>                         pstmt.close();
> 
> WARNING: copy: line 2, UtfToLocal: could not convert UTF-8 (0xe47469).
> Ignored 
> 
> But  wenn I use same command  from psql console in DB  I can import all
> of the special letter,
> 
>   copy public.liq_import from '/home/kerdem/upstream/LIQ.txt' delimiter
> ';'  NULL as '' ;
> 

I imagine this problem is a result of the JDBC driver setting the 
client_encoding variable to unicode (which it needs to function properly), 
this is making the COPY command think the file has a unicode encoding.  
When connecting with psql your client_encoding defaults to the database 
encoding which I imagine is what the file is encoded as.

As to how to solve this problem?  It is possible to SET the 
client_encoding temporarily and then reset it after the COPY is done, but 
this is something I hesitate to recommend because it's definitely not 
something the JDBC driver wants you doing.  I'm not sure what else to 
could be done, extend the COPY command to take an encoding argument?

Kris Jurka

In response to

pgsql-jdbc by date

Next:From: Kris JurkaDate: 2004-03-15 06:55:45
Subject: Re: About use SSL by JDBC
Previous:From: Kris JurkaDate: 2004-03-14 03:09:22
Subject: Re: About using drivers....

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group