Link to home
Create AccountLog in
Avatar of EmadGirgis
EmadGirgis

asked on

Java JDBC mysql internaltional character set

I am writing a small application to manage website sales. Some of the files we get have text in other languages... for example Russian.

When I wrote this application in Access, I had a problem with the foreign language text appeared in different symbols.

my new development is Java, JDBC, mysql... I know Java have huge support for this... I don't know anything about this topic... Can you help me... I am really novice...
I am an older person who is not in college nor this for an assignment. Help is much appreciated0
Oh, i almost forgot... I am using netBeans IDE.
Avatar of garypfirstech
garypfirstech

Have a look at the JDBC tutorial at http://www.jdbc-tutorial.com/ or http://download.oracle.com/javase/tutorial/jdbc/index.html.

The MySQL JDBC driver, called Connector J,  can be downloaded from http://www.mysql.com/downloads/connector/j/
Avatar of EmadGirgis

ASKER

Well,

I have the code that does java and JDBC already... my issue was with the international character support.

I can connect to mysql and to my older ms access data...
Please I need to know how to handle and store strings that are from different languages too.
Avatar of CEHJ
>> I need to know how to handle and store strings that are from different languages too.

Use UTF-8 if you have mixed languages. That encoding can handle any language
So,
I choose utf8_unicode_ci for the character set in mysql.
Do I need to do anything with my java code?
So I am reading a table record (field ) that contain such mixed language characters.... Can my strings handle those characters..

You want to try to avoid Java altogether if possible
I'm not sure what you're asking.  All Strings in java are encoded in Unicode so they should handle any language.  If you're asking how to convert a byte array read in from a file in a foreign language, need to determine the charset encoding that was used to create the file.  For example, the cyrillic language can be encoded as ASCII ISO Latin aka ISO-8859-5 so to convert the byte array, you'd code:

 
String russianString = new String(byteArray, "ISO-8859-5");

Open in new window


You could also read the file directly into a String by using an appropriate Reader such as:

BufferedReader myReader = new BufferedReader(InputStreamReader(new
                                               FileInputStream(myFileName), "ISO-8859-5"));

Open in new window


In any event, your most important first task is to find out the charset encoding that was used to create the file.
ASKER CERTIFIED SOLUTION
Avatar of garypfirstech
garypfirstech

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account