pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
JDBC COPY error encoding
3+ messages / 2 participants
[nested] [flat]

* JDBC COPY error encoding
@ 2007-08-20 14:18 ttvvaa <ttvvaa@gmail.com>
  2007-08-21 15:21 ` Re: JDBC COPY error encoding Kalle Hallivuori <kato@iki.fi>
  0 siblings, 1 reply; 3+ messages in thread

From: ttvvaa @ 2007-08-20 14:18 UTC (permalink / raw)
  To: pgsql-jdbc


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?



-- 
View this message in context: http://www.nabble.com/JDBC-COPY-error-encoding-tf4299167.html#a12236825
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: JDBC COPY error encoding
  2007-08-20 14:18 JDBC COPY error encoding ttvvaa <ttvvaa@gmail.com>
@ 2007-08-21 15:21 ` Kalle Hallivuori <kato@iki.fi>
  2007-08-21 19:38   ` Re: JDBC COPY error encoding ttvvaa <ttvvaa@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Kalle Hallivuori @ 2007-08-21 15:21 UTC (permalink / raw)
  To: ttvvaa <ttvvaa@gmail.com>; +Cc: pgsql-jdbc

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/



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: JDBC COPY error encoding
  2007-08-20 14:18 JDBC COPY error encoding ttvvaa <ttvvaa@gmail.com>
  2007-08-21 15:21 ` Re: JDBC COPY error encoding Kalle Hallivuori <kato@iki.fi>
@ 2007-08-21 19:38   ` ttvvaa <ttvvaa@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: ttvvaa @ 2007-08-21 19:38 UTC (permalink / raw)
  To: pgsql-jdbc


Thanks for answer!
I convert text-file to UTF-8 and successed copy.


Kalle Hallivuori wrote:
> 
> Hi!
> 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/
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
> 
>                 http://www.postgresql.org/about/donate
> 
> 

-- 
View this message in context: http://www.nabble.com/JDBC-COPY-error-encoding-tf4299167.html#a12261732
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2007-08-21 19:38 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-08-20 14:18 JDBC COPY error encoding ttvvaa <ttvvaa@gmail.com>
2007-08-21 15:21 ` Kalle Hallivuori <kato@iki.fi>
2007-08-21 19:38   ` ttvvaa <ttvvaa@gmail.com>

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