Re: pgsql, java and accents

Lists: pgsql-general
From: Fernando Lozano <fsl(at)centroin(dot)com(dot)br>
To: redhat-list(at)redhat(dot)com, pgsql-general(at)postgresql(dot)org
Subject: pgsql, java and accents
Date: 2002-01-30 19:31:10
Message-ID: 3C5849FE.9070803@centroin.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi there!

Running Red Hat Linux 7.1 and PostgreSQl 7.1.3 installed fomr the PGDG
rpms availabe at postgresql.org. My Java apps (using IBM Java SDK 1.3.0)
works fone with the database, but all accented characters (á, ã ó, ç,
...) get garbaged.

From psql I can insert and see the acents but Java cannot insert or
read the accents. Is this a bug of the driver or something I can fix
with a simple configuration? I've alread read posggresql manual and
found nothing. :-(

[]s, Fernadno Lozano


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fernando Lozano <fsl(at)centroin(dot)com(dot)br>
Cc: redhat-list(at)redhat(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: pgsql, java and accents
Date: 2002-01-30 20:00:36
Message-ID: 25517.1012420836@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Fernando Lozano <fsl(at)centroin(dot)com(dot)br> writes:
> Running Red Hat Linux 7.1 and PostgreSQl 7.1.3 installed fomr the PGDG
> rpms availabe at postgresql.org. My Java apps (using IBM Java SDK 1.3.0)
> works fone with the database, but all accented characters (, , ,
> ...) get garbaged.

> From psql I can insert and see the acents but Java cannot insert or
> read the accents. Is this a bug of the driver or something I can fix
> with a simple configuration?

I believe the JDBC driver is sensitive to the character set encoding
reported by the database, because it will try to convert encodings to
what Java wants. psql on the other hand is probably just passing the
characters through without any munging.

Try psql -l to see what encoding is reported. You may need to drop and
recreate the database if it's the wrong encoding.

regards, tom lane


From: Fernando Lozano <fsl(at)centroin(dot)com(dot)br>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: redhat-list(at)redhat(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: pgsql, java and accents
Date: 2002-01-31 01:39:57
Message-ID: 3C58A06D.337D28D8@centroin.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi there!

Found the cause and I guess many people will be surprised. I found the
info on the JDBC 2.0 conformance tests at jdbc.postgresql.org.

It looks that recent versions of PostgreSQL, if compiled without
multi-byte characters suport (as are the RPM packages) will *allways*
respond to the JDBC driver it's working on US7_ASCII. That's why I could
not read nor write accents from Java, only from psql. Java was told to
use 7-but ASCII.

The workaround is described on the same doc: you have to append
"?charSet=ISO8859-1" to the connectionURL (or pass it as properties).
Actually the doc suggested UTF-8 but it didn't worked for me. ISO8859-1
worked fine.

Hope this helps other non-english speakers like me. :-)

[]s, Fernando Lozano