Hello, i have a problem with using a java application with MySQL database, i can insert arabic text and read it in mysql ( i changed the charset and encoding for database ), but in the java application i can only read it if it is arabic but when i change a text into arabic (even if it was originally in arabic ) it looks and saves in the database like this: ??????. I thought that if mysql is able to write and read arabic normally then it is a problem of query statements in the java application. i think i should put something there. Can anyone help me solve this problem, i really need help with this one. Thanks for all help.
My advice is to use UTF-8 it's universal encoding. And run SET NAMES 'utf8'; after connecting to DB: Make sure you back up the database
Well, i am actually using UTF-8 in the database, but this "set names utf8" i don't know where to put it, i mean : "mysql_query('SET NAMES utf8', $link);" this is a PHP code right? but where can i use it in a java application.
If it helps the select statement in the java application is "select * from tablename where id=....." , note that the id is a string but in English. But when i use the update statement to write Arabic language, the text becomes ?????. According to what you said Martin i need to determine the encoding after connecting to the database. but what is the code for this and where to put it in a java application.
I have no idea why you write php in javascript. However, you have somewhere a connection to the database find it and put this on the next row, its possible the connection to be in external file. the connection is like mysql_connect('host', 'user', 'password'); Use ctrl+F to search for "mysql_connect" Instead SET NAMES, you can use or to see the current encoding use
I am not using javascript, i am using a java application. But thanks for the help, i already found the solution for it. It's the same concept, i should define the encoding as utf8 after connecting to the database but the code in java is different.
First you have to set the database encoding to "UTF-8" and collation to "UTF8_general_ci" Then when connecting to the database in the java code use this "jdbc:mysql:localhost/Database1?useUnicode=true&characterEncoding=utf8".