0

i am building a server application using eclipse , and the client is android application

when i used just Java application i can read arabic chars from mysql and can print it correctly to eclipse ,but on server application i can't , the results are question marks like this `?????`

i am trying to print the results on eclipse not on android

my connect to database is :

String unicode = "?useUnicode=yes&characterEncoding=UTF-8";
Class.forName("com.mysql.jdbc.Driver");
            con = (Connection) DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/ams-competation" + unicode,
                    username, password);

don't care about android , i am asking how to read and print arabic chars on eclipse server application

EDIT

seems like my problem is from the eclipse not from the connection because when i tried this System.out.println("روما"); , i got question marks and when i tried to check that question marks with this statements

if(q.getFirstChoice().equals("بيرلو"))
                System.out.println("dddd");

the results was dddd , so i can read it correctly from mysql , but my problem on printing the results

4

1 に答える 1

1

問題は文字system.outをサポートしていないためUtF-8、次のコードを使用する必要があります

PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
out.println(“some-utf8-string”);

リファレンスもご覧いただけます。

編集
他の回避策は

  • [実行構成] の [引数] タブで、VM 引数に「-Dfile.encoding=UTF-8」を追加しました
  • 実行構成の共通タブで、コンソールのエンコーディングを UTF-8 に設定しました
于 2012-06-22T13:04:21.933 に答える