Korean Characters

Hi,

I am having a problem in storing korean characters in MSSQL database using JSP. I had this problem previously on Thai characters, and somebody solved it for me by adding in this tag on the JSP page.

<%@ page pageEncoding="UTF-8"%>

And before I did any request.getparameter() , I just need to add in another tag:
request.setCharacterEncoding("UTF-8");

By using this, it solved the Thai problem, the thai characters will be stored exactly into the database.


Now, it seems that I can't use this same solution for storing and displaying korean characters. Everything will be stored as ??????? (Questions marks)


BUT, it works if I store the characters in this formatl, &#12615;&#12609;&#12615;&#12603;

I'm not sure whether we can use UTF-8 for korean characters. When I used this tag:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>

Then it works, but storing this format into the db:&#12615;&#12609;&#12615;&#12603;


I want to store exactly the korean characters into the MSSQL, not in the format above. Could anybody give me some suggestions?



Regards,
rospcc
rospccAsked:
Who is Participating?
 
GranModCommented:
PAQed with points refunded (500)

GranMod
Community Support Moderator
0
 
suprapto45Commented:
Hi,

I think that you can try from the list of encodings in this URL.

http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html

Additionally, do not forget to include charsets.jar into your app if you use the extended encoding.

David
0
 
suprapto45Commented:
Btw,

Let me try that :)

David
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
rospccAuthor Commented:
Hi David,

Thanks for the information, at least I have something to start on. And one more information for you to take note, I need the JSP to be able to show both Korean and Thai characters. My current implementation can only work for one at a time. When I use UTF-8, it only works for Thai. When I use another encoding, it only works for Korean.


Regards,
Jenty
0
 
suprapto45Commented:
Hi,

Is this the problem on storing your Korean into DB or the way it renders to JSP?

I think that Korean should also be available in UTF-8

David
0
 
rospccAuthor Commented:
Yes, I wanted to store the Korean characters into DB. Now I can only store THai if I use UTF-8
0
 
suprapto45Commented:
Mmm....

Okay, to render it to JSP, it is okay to use UTF-8 as UTF-8 should be able to handle Korean as well. The problem would be on the way you save the data into DB.

Can you post your JSP to store the data to DB? I need to see your Java codes as well. What is the type of column that you use to store this foreign language in MSSQL

Thanks
David
0
 
rospccAuthor Commented:
Ok, the datatype of the field is nvarchar. On top of every jsp codes I will also add request.setCharacterEncoding("UTF-8"); to make sure that all user inputs will be converted to UTF-8.

Here is my java codes of insertion to the database:

public void addRecord(String name) throws SQLException, Exception {                        

     String sql = "Insert into TB_Competency (CompetencyName) values ('" + name + "')";
            
                                //another function to open database connection            
            db.openDB();            
            PreparedStatement ps = db.getCon().prepareStatement(sql);
                  
            ps.executeUpdate();
                  
            db.closeDB();
            
                        

}

Is there anything that has to do with the database collation? I am using the default one which seems being set as Thai...But anyway I tried to change to Korean, it didn't work either.
0
 
fargoCommented:
Hi,

UTF-8 for jsps is all correct for handling korean. In terms of DB you need to change the character encoding in the database.The character set of the database server is chosen during the MSSQL installation and cannot be changed. That means that one server can support only one character set. Use the unicode data types it supports storing of all character sets.

May be u need to shutdown the database, change the character encoding and start again. Please check more with the database administrator about it.

fargo

0
 
suprapto45Commented:
Hi,

Sorry, I was away in the weekend.

If you can insert Thai characters correctly using UTF-8, you should not have a problem on inserting Korean characters to DB as well. It could be a problem on DB side as what fargo suspected.

David
0
 
rospccAuthor Commented:
Hi,

I suspected so too..I'll take a look at the DB site first, will come back to you guys...Thanks.


Cheers,
rospcc
0
 
rospccAuthor Commented:
Hi,

If I tried to key in straight away to DB, which is throuh Enterprise Manager, it was alright. And when I tried to display from JSP, it was alright too. Only when I inserted from JSP and passed through Java, then it didn't work.


Regards,
rospcc
0
 
suprapto45Commented:
Hi,

Weird. It should work fine. Let me check your codes again.

David
0
 
suprapto45Commented:
Hi,

Try to add
<%@page language="java" contentType="text/html;charset=UTF-8"%>

at top on every of your JSP. Honestly, they should be the same but just give it a try ;)

David
0
 
rospccAuthor Commented:
I have added that. Sorry I forgot to post some more information. I found out the problem is not with the JSP or the application, but with the MSSQL setting itself. I think it has to do with the DB Collation.

When I set the collation to Korean_Wansung_CI_AS, it works alright whether you insert from DB direct or from JSP. Now, my problem is, we have to cater for different languages to be stored in one database. Currently, we have Thai and Korean. So, if I set the collation to Korean, it cannot accept Thai anymore. I wonder whether Microsoft does allow to store different languanges in a database.


Regards,
rospcc
0
 
suprapto45Commented:
Glad you have found the problem.

For better solution, you may be interested asking that DB Collation in the MS SQL Forum in EE.


David
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.