Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 1F5819F98AF for ; Tue, 21 Aug 2007 12:21:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 71462-04 for ; Tue, 21 Aug 2007 12:21:23 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.191]) by postgresql.org (Postfix) with ESMTP id E12399F97D0 for ; Tue, 21 Aug 2007 12:21:22 -0300 (ADT) Received: by rv-out-0910.google.com with SMTP id l15so1187310rvb for ; Tue, 21 Aug 2007 08:21:21 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=XjkXBJ4i0UIbvl7UeOJPANwfDY4KMijIrR2egd5IlUCIb+Z2D7TXQM1Wka7an2RB1bnWgAwyqMFgOzU3KPhkJ7sqFcp7aNYRITAkTI/KyjOO+62Z9ewoaq7I/he9FMpZUu7/hIyLTdFUV+hV9tL7VipjtIE4I5/+2+Q/7afzSYc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=RhUiNEr4g2P6S6IceUTZdzcxo5yMRlw9ZVkNz3xzr7tYNCEuF9RuvR+WYrrE5bNjsjRC8Jwcq7DKGeBgxrhlRpKGhV+FsK/OZBBORmfQEl9JDDwQSi+IZaviXZaQ3t7vCIxN2esgNICmqdAw2/texnmH485Cqlpa8U9ZJZWhg2g= Received: by 10.114.149.2 with SMTP id w2mr1797740wad.1187709681359; Tue, 21 Aug 2007 08:21:21 -0700 (PDT) Received: by 10.114.147.16 with HTTP; Tue, 21 Aug 2007 08:21:21 -0700 (PDT) Message-ID: Date: Tue, 21 Aug 2007 18:21:21 +0300 From: "Kalle Hallivuori" To: ttvvaa Subject: Re: JDBC COPY error encoding Cc: pgsql-jdbc@postgresql.org In-Reply-To: <12236825.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <12236825.post@talk.nabble.com> X-Google-Sender-Auth: 0d93450d5345bd44 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/87 X-Sequence-Number: 17400 Hi! 2007/8/20, ttvvaa : > 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/