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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
suprapto45Commented:
Btw,

Let me try that :)

David
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
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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
rospccAuthor Commented:
Yes, I wanted to store the Korean characters into DB. Now I can only store THai if I use UTF-8
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
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.
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

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
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
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
suprapto45Commented:
Hi,

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

David
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
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
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
GranModCommented:
PAQed with points refunded (500)

GranMod
Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.