Skip site navigation (1) Skip section navigation (2)

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-01 01:20:43
Message-ID: 20030801012043.59182.qmail@web13004.mail.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
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")

** "pgsql" is the java bean handling resultset
 
Best Regards,
  Eric Tan

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


On Thu, 31 Jul 2003, [big5] Eric Tan wrote:

> The command only work in command prompt - putty":
> ALTER DATABASE "CA_care" SET client_enconding TO 'big5';
>
> But it fail when inserting from jsp & VB.
> I have to run this code in all program which may access database.
> pgsql.execute("set client_encoding to 'Big5';");
>
> Any other solution?

The idea is that you run the ALTER DATABASE command once and then every
time you connect it will already be set, so you do not need to make that
call in your client. Notice the second time I connect the client_encoding
is already set.

jurka(at)doug:~$ psql tantest
Welcome to psql 7.3.3, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

tantest=# show client_encoding;
client_encoding
-----------------
SQL_ASCII
(1 row)

tantest=# alter database tantest set client_encoding to big5;
ALTER DATABASE
tantest=# \q
jurka(at)doug:~$ psql tantest
Welcome to psql 7.3.3, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

tantest=# show client_encoding;
client_encoding
-----------------
big5
(1 row)



To check if you have correctly run the ALTER DATABASE statement, check

SELECT datconfig FROM pg_database WHERE datname='';

You should see
tantest=# select datconfig FROM pg_database where datname='tantest';
datconfig
------------------------
{client_encoding=big5}
(1 row)


Kris Jurka



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

In response to

Responses

pgsql-jdbc by date

Next:From: R.W. HartungDate: 2003-08-01 02:19:06
Subject: new user rpm content question.
Previous:From: Jason SandoDate: 2003-08-01 01:15:22
Subject: No function escape processing?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group