Re: Encoding from CopyManager.copyIn()

Поиск
Список
Период
Сортировка
От Kris Jurka
Тема Re: Encoding from CopyManager.copyIn()
Дата
Msg-id alpine.BSO.2.00.0907221538320.17424@leary.csoft.net
обсуждение исходный текст
Ответ на Encoding from CopyManager.copyIn()  (Markus Kickmaier <markus.kickmaier@apus.co.at>)
Список pgsql-jdbc

On Wed, 22 Jul 2009, Markus Kickmaier wrote:

> I'm using the copyIn() function of the CopyManager. It works fine until
> I don't use an "umlaut" like ?. Then i get an PSQLException:
>
> org.postgresql.util.PSQLException: ERROR: invalid byte sequence for
> encoding "UTF8": 0xfc
>
> My code looks like follows:
>
> ByteArrayOutputStream output = new ByteArrayOutputStream();
> PrintWriter writer = new PrintWriter(output);
> writer.println("abc???");
> writer.flush();
> ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
> long result = ((PGConnection) con_).getCopyAPI().copyIn(statement, input);

You should be using the copyIn(String, Reader) function rather than
InputStream.  That way the CopyManager can encode the provide data to
the database in the encoding it requires.

If using the InputStream method, you need to provide the data in UTF-8
encoding.

Kris Jurka


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Markus Kickmaier
Дата:
Сообщение: Encoding from CopyManager.copyIn()
Следующее
От: Ondřej Fafejta
Дата:
Сообщение: COPY SELECT with parameters