Re: [BUG] - Invalid UNICODE character sequence found(0xc000)

From: "Antonio Gallardo" <antonio(at)apache(dot)org>
To: "Kris Jurka" <books(at)ejurka(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [BUG] - Invalid UNICODE character sequence found(0xc000)
Date: 2004-01-09 14:05:49
Message-ID: 35242.10.0.0.5.1073657149.squirrel@ags01.agsoftware.dnsalias.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

This is the ofending SELECT:

SELECT A0.ROL_NAME,A0.ROL_ENABLE,A0.ROL_ID FROM AUTH_ROLE A0 WHERE
(A0.ROL_NAME LIKE 'z%') AND A0.ROL_NAME <> 'admin' ORDER BY 1

I tried it using squirrelSQL - http://squirrel-sql.sourceforge.net/ and
even in psql it returns:

ERROR: Invalid UNICODE character sequence found (0xc000)

in psql the "SELECT version();" returns:

PostgreSQL 7.3.4-RH on i386-redhat-linux-gnu, compiled by GCC
i386-redhat-linux-gcc (GCC) 3.3.2 20031022 (Red Hat Linux 3.3.2-1)

Lets focus on:

(A0.ROL_NAME LIKE 'z%')

If I query:

(A0.ROL_NAME LIKE 'za%') --- It is OK, but

(A0.ROL_NAME LIKE 'az%') --- throw the same exception

Looks like PostgreSQL incorrect manage this sequence: "z%"

Can you test it in a table while doing a similar cosntruction?

Can you check this?

Best Regards,

Antonio Gallardo.

Csaba Nagy dijo:
> Antonio,
>
> As Kris Jurka said in his posts, there's nothing special with the "z"
characters, so your browser/os must be doing something wrong with the
input. But the error you reported is a clear indication that the backend
gets a byte sequence which is not properly encoded as UTF-8. If you pass
only strings to the driver, then this is a driver error (means the
driver encodes the string improperly).
> To facilitate reproduction, I would suggest you to print out the unicode
characters of your query string with something like:
>
> ... embed this in your program:
>
> for (int i = 0; i < queryString.length(); i++) {
> System.out.print("\\u");
> System.out.print(toHexString(queryString.charAt(i)));
> }
> System.out.println();
> ...
> private static final char[] hexChars =
> { '0', '1', '2', '3', '4', '5', '6',
> '7', '8', '9', 'A', 'B', 'C', 'D',
> 'E', 'F' };
>
> public static String toHexString(int n)
> {
> char[] buffer = new char[4];
> for (int i=0; i<4; i++) {
> buffer[3-i] = hexChars[n & 0x0F];
> n >>= 4;
> }
> return new String(buffer);
> }
>
> Then you can use the resulting string in the example program. This will
make sure that the other person on the other end of the email will have
exactly the same string as you - otherwise the you can bet that subtle
encoding differences get lost as you type.
>
> Cheers,
> Csaba.
>
>
> On Fri, 2004-01-09 at 06:18, Antonio Gallardo wrote:
>> Hi:
>>
>> First, here is the postgreSQL version used:
>> PostgreSQL 7.3.4-RH on i386-redhat-linux-gnu, compiled by GCC
>> i386-redhat-linux-gcc (GCC) 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
>>
>> I am aware similar problem was already sent to this list (I read some
of them), but I want to contribute with more interesting stuff:
>>
>> In the tested web application, we use postgreSQL JDBC driver. We have a 1
>> field form where we allow the user to writte a search pattern a table. The
>> generated SQL use LIKE to find for similars. Example:
>>
>> If the user write: "ant" then the answer will be:
>>
>> antonio
>> antoine
>> etc.
>>
>> This works fine, even if we left empty the form field, to show all the
records.
>>
>> The interesting stuff I found is:
>>
>> If we write just "z", "Z" or any string with that include the chars "z" or
>> "Z" at any point of the string in the field, then I got the below
error. How is this posible? I not an UTF-8, ISO-8859-1 or SQL_ASCII
expert, but for me "z" or "Z" is part of the ASCII that means a 1 byte
code in UTF-8.
>>
>> That means the driver has problems with an normal "z" or "Z"?
>>
>> Note: The same apply for the drivers:
>>
>> pg73jdbc.jar
>> pg74jdbc.jar
>> pg74.1jdbc.jar
>>
>> Please explain.
>>
>> Best Regards,
>>
>> Antonio Gallardo
>>
>> Caused by: java.sql.SQLException: ERROR: Invalid UNICODE character
sequence found (0xc000)
>>
>> at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131) at
>> org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:505)
at
>> org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:320)
at
>> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48)
at
>> org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statement.java:153)
>>
>> ---------------------------(end of
broadcast)--------------------------- TIP 5: Have you checked our
extensive FAQ?
>>
>> http://www.postgresql.org/docs/faqs/FAQ.html
>

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Antonio Gallardo 2004-01-09 14:18:25 Re: [BUG] - Invalid UNICODE character sequence found(0xc000)
Previous Message Dave Cramer 2004-01-09 13:46:46 Re: PreparedStatement parameters and mutable objects