Re: How to insert Chinese (big5) through JDBC?

From: Kris Jurka <books(at)ejurka(dot)com>
To: Eric Tan <neltan2002(at)yahoo(dot)com(dot)hk>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: How to insert Chinese (big5) through JDBC?
Date: 2003-08-02 10:38:35
Message-ID: Pine.LNX.4.33.0308020617450.10101-100000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Fri, 1 Aug 2003, [big5] Eric Tan wrote:

> I guess it was. I doesn't.
>
> CA_care=# SELECT datconfig FROM pg_database WHERE datname='CA_care';
> datconfig
> ------------------------
> {client_encoding=Big5}
>
> CA_care=# \encoding
> EUC_TW
> When I select fields with Chinese content in jsp, it cannot display
> correctly, unless I add this: pgsql.execute("set client_encoding to
> 'Big5';"); and get it pgsql.getChinese2("receivedfrom")

Yes, I apologize for having steered you wrong. After some further
investigation, the approach I mentioned will work for other clients, but
not for JDBC. The postgresql JDBC driver does a SET client_encoding =
'UNICODE' when it first starts up which overwrites any default value
assigned to a user or database. The paradigm it seems to be working with
is that anything Java based should be working with Unicode data only, and
it will let the backend do the encoding conversion between Unicode and the
server encoding. This means you need to alter your code to convert from
Big5 to Unicode to work with this system although I'm not sure what the
best way to do this is.

You mentioned that this was a jsp application, what is the default
character encoding for the application server? Does adjusting that help?

Kris Jurka

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jesus Sandoval 2003-08-02 11:23:10 Server side resultset search (for performance reasons)
Previous Message dragos 2003-08-02 08:51:05 java object store