?
Solved

Korean Characters

Posted on 2006-03-23
17
Medium Priority
?
707 Views
Last Modified: 2013-12-03
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
0
Comment
Question by:rospcc
16 Comments
 
LVL 16

Expert Comment

by:suprapto45
ID: 16278273
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
 
LVL 16

Expert Comment

by:suprapto45
ID: 16278280
Btw,

Let me try that :)

David
0
 

Author Comment

by:rospcc
ID: 16278325
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 16

Expert Comment

by:suprapto45
ID: 16278356
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
 

Author Comment

by:rospcc
ID: 16278434
Yes, I wanted to store the Korean characters into DB. Now I can only store THai if I use UTF-8
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 16278496
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
 

Author Comment

by:rospcc
ID: 16278543
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
 
LVL 11

Expert Comment

by:fargo
ID: 16279466
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
 
LVL 16

Expert Comment

by:suprapto45
ID: 16296856
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
 

Author Comment

by:rospcc
ID: 16309767
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
 

Author Comment

by:rospcc
ID: 16379135
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
 
LVL 16

Expert Comment

by:suprapto45
ID: 16397569
Hi,

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

David
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 16397648
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
 

Author Comment

by:rospcc
ID: 16397740
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
 
LVL 16

Expert Comment

by:suprapto45
ID: 16398431
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
 

Accepted Solution

by:
GranMod earned 0 total points
ID: 16655840
PAQed with points refunded (500)

GranMod
Community Support Moderator
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question