W3C home > Mailing lists > Public > www-international@w3.org > April to June 2002

RE: Problem in java with getting japanese values from database

From: <chris@globalsight.com>
Date: Wed, 19 Jun 2002 07:36:51 -0700
Message-ID: <9EAF88ECBC9ED511969600306E00E66E09EAB0@equinox>
To: mubariz_kharbe@infosys.com
Cc: www-international@w3.org

>Hi
>
>I am using SQL server2000 and jakarta tomcat 3.1
>If I try to fetch japanese data from the database
>I get the value as ??. The db driver that I am
>using is sun.jdbc.odbc.JdbcOdbcDriver
>
>How do I get correct japanese values from the
>database?
>
>regards
>Mubariz

Depending on the column datatype and your
JDBC driver you may need to denote quote-
delimited Unicode data in your SQL statements
with an 'N' like in this INSERT:

insert into items(
   id, ..., item_ntext
)values(
   1001, ..., N"Some Japanese text"
)

Then again this may only apply to INSERTs
and UPDATEs.

Or could you be seeing the JSP problem
that JDBC returns the UTF-8 data as a
stream of ISO-8859-1 which therefore
needs to be "decoded" as UTF-8 like this:

   String f=request.getParameter("data");
   if(f!=null){
      f = new String(f.getBytes("ISO-8859-1"), "UTF-8");
   }

/Chris

Chris Cowperthwait
Sr. Technical Consultant
Professional Services
GlobalSight Corporation
E: chris@globalsight.com
P: (720) 622-4005
F: (720) 622-4001
M: (303) 249-2188
Received on Wednesday, 19 June 2002 10:37:31 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 2 June 2009 19:16:59 GMT