pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Csaba Nagy <nagy@ecircle-ag.com>
To: Altaf Malik <mmalik_altaf@yahoo.com>
Cc: James Im <im-james@hotmail.com>
Cc: Postgres JDBC <pgsql-jdbc@postgresql.org>
Subject: Re: invalid byte sequence for encoding "UTF8": 0x00
Date: Tue, 20 Feb 2007 12:13:39 +0100
Message-ID: <1171970019.3101.328.camel@coppola.muc.ecircle.de> (raw)
In-Reply-To: <793207.12351.qm@web39108.mail.mud.yahoo.com>
References: <793207.12351.qm@web39108.mail.mud.yahoo.com>

I've had the same error, and it is in fact because in Java you can
actually have a "0x0" character in your string, and that's valid
unicode. So that's translated to the character 0x0 in UTF8, which in
turn is not accepted because the server uses null terminated strings...
so the only way is to make sure your strings don't contain the character
'\u0000'.

I identified the place in my code which was generating such a character
and fixed, and I didn't have other problems after that... even if I
still think forbidding a valid character is a somewhat arbitrary
restriction.

HTH,
Csaba.

On Tue, 2007-02-20 at 11:57, Altaf Malik wrote:
> Try to change the encoding of your database to "Unicode". 
> I hope this helps.
>  
> --Altaf Malik
> EnterpriseDB
> www.enterprisedb.com
> James Im <im-james@hotmail.com> wrote:
>         Hi,
>         
>         I've got another problem. I sometimes get the following
>         SQLException
>         when doing an insert:
>         
>         ERROR: invalid byte sequence for encoding "UTF8": 0x00
>         Exception: org.postgresql.util.PSQLException
>         org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1525)
>         org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1309)
>         org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
>         org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
>         org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
>         org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:308)
>         
>         By the way, the insert is done with a PreparedStatement and I
>         use only
>         setLong(), setString(), setTimestamp() and setInt().
>         
>         
>         I don't understand it very well. It is obviously an encoding
>         exception
>         but I don't know why it happens and what I could do avoid it.
>         
>         Any idea?
>         
>         _________________________________________________________________
>         Opret en personlig blog og del dine billeder på MSN Spaces: 
>         http://spaces.msn.com/
>         
>         
>         ---------------------------(end of
>         broadcast)---------------------------
>         TIP 1: if posting/reading through Usenet, please send an
>         appropriate
>         subscribe-nomail command to majordomo@postgresql.org so that
>         your
>         message can get through to the mailing list cleanly
> 
> 
> ______________________________________________________________________
> Don't get soaked. Take aquick peak at the forecast 
> with theYahoo! Search weather shortcut.




view thread (29+ messages)  latest in thread

Message-ID: <1171970019.3101.328.camel@coppola.muc.ecircle.de>
Permalink:  ../1171970019.3101.328.camel@coppola.muc.ecircle.de/
Also on:    postgresql.org/message-id/1171970019.3101.328.camel@coppola.muc.ecircle.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: nagy@ecircle-ag.com, mmalik_altaf@yahoo.com, im-james@hotmail.com, pgsql-jdbc@postgresql.org
  Subject: Re: invalid byte sequence for encoding "UTF8": 0x00
  In-Reply-To: <1171970019.3101.328.camel@coppola.muc.ecircle.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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