Re: PostgreSQL JDBC Driver versus Encoding

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Joao(dot)Pires(at)iscte(dot)pt
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: PostgreSQL JDBC Driver versus Encoding
Date: 2007-10-20 00:21:13
Message-ID: 471949F9.8020304@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

João Paulo Pires wrote:

> I have a PostgreSQL database which encoding is SQL_ASCII.

This is the cause of your problem. SQL_ASCII provides essentially no
encoding information at all, so the JDBC driver does not know how to
translate between the database and Java's internal UTF-16
representation. If you are going to be inserting anything other than
7-bit-ASCII text into it, you are going to have problems.

If you can, try using a database encoding that can represent the data
you are inserting. UTF8 / UNICODE is probably a good choice unless you
have special requirements. See
http://www.postgresql.org/docs/8.2/static/multibyte.html especially the
bit that says:

> The SQL_ASCII setting behaves considerably differently from the other settings. When the server character set is SQL_ASCII, the server interprets byte values 0-127 according to the ASCII standard, while byte values 128-255 are taken as uninterpreted characters. No encoding conversion will be done when the setting is SQL_ASCII. Thus, this setting is not so much a declaration that a specific encoding is in use, as a declaration of ignorance about the encoding. In most cases, if you are working with any non-ASCII data, it is unwise to use the SQL_ASCII setting, because PostgreSQL will be unable to help you by converting or validating non-ASCII characters.

-O

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2007-10-20 17:48:34 Re: Unable to prepare a statement when the object names contain more than one $ symbol
Previous Message John R Pierce 2007-10-20 00:18:16 Re: PostgreSQL JDBC Driver versus Encoding