Re: I can't insert the chinese words.

Поиск
Список
Период
Сортировка
От Daniel Bruce Lynes
Тема Re: I can't insert the chinese words.
Дата
Msg-id 200303032253.00168.dlynes@shaw.ca
обсуждение исходный текст
Ответ на I can't insert the chinese words.  (dauw <dauw@ms9.url.com.tw>)
Список pgsql-jdbc
On Tuesday 18 February 2003 01:25, dauw wrote:

> Hello all,
> I use the  "(2003-02-09) JDBC3 JDK 1.4" JDBC driver to access the DB.
> When I insert the chinese words (local= zh_TW ,"BIG5") into the varchar
> column,it become "???".
> But if I use the pgAdmin to do so ,It is success.
>
> Then I select the ResultSet, The getString() mathod could not get the
> correct words.
> But if I use the sentence " String s =new String(rs.getBytes());" ,The
> string s is correct.
>
> I guess that is caused by char= 16-bit in java2.
>
> Now how can I insert the chinese words (local= zh_TW ,"BIG5") into the
> varchar column by jdbc?

I would imagine Big5 isn't any different from GB, so here goes:

String str=new String( "中国" ) ;
byte[] b=str.getBytes("iso-8859-1") ;
str=new String( b, "gb2312" ) ;

stmt.setString(1, str ) ;

This is assuming you weren't treating the Chinese as Chinese, originally.

And to get them back out:

String str=rs.getString(1) ;

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Peter Royal
Дата:
Сообщение: DatabaseMetaData.getImportedKeys returning duplicate rows
Следующее
От: Joe Howes
Дата:
Сообщение: Tips on Sun ONE App Server 7 and Postgres 7.2