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

From: Eric Tan <neltan2002(at)yahoo(dot)com(dot)hk>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: How to insert Chinese (big5) through JDBC?
Date: 2003-08-04 00:59:13
Message-ID: 20030804005913.53807.qmail@web13006.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Thank you very much. Kris Jurka.
I'm now understand !

I will change the connection bean. Add the line required there.

You mentioned client_encoding works for some clients. What are they?

Or can I change JDBC driver ? Where is the "set client_encoding" in JDBC ?

Best Regards,
neltan

Kris Jurka <books(at)ejurka(dot)com> wrote:

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

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

最新鈴聲推介:十面埋伏,多謝失戀,心淡...
http://ringtone.yahoo.com.hk

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Renaud Waldura 2003-08-04 06:00:58 PostgreSQL & TopLink
Previous Message Scot P. Floess 2003-08-03 20:52:56 Re: Server side resultset search (for performance reasons)