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-07-31 10:39:19
Message-ID: Pine.LNX.4.33.0307310632300.19468-100000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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='<dbname>';

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

Kris Jurka

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Rich Cullingford 2003-07-31 19:03:17 SSL support in PG 7.4
Previous Message Eric Tan 2003-07-31 09:53:12 Re: How to insert Chinese (big5) through JDBC?