I have coded a php project that is connected a mysql database. Also I have a jar file, which runs when a php url is called. Through php I take parameters from user and save them to database and after that my jar file gets connected to database and reads the specified rows. Until here everything is ok.
This is my php file that runs .jar file located in the server:
<?php
mysql_query("SET NAMES utf8");
header("Content-Type: text/html;charset=UTF-8");
echo shell_exec('java -jar /home/path/path/path/my.jar');
?>
and my jar file as follows:
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/somedb?useUnicode=true&characterEncoding=UTF-8", "root", "pass");
in the while loop:
while (resultSet2.next()) {
title2 = new String(resultSet2.getString("title").getBytes("UTF-8"), "UTF-8");
url2 = new String(resultSet2.getString("url").getBytes("UTF-8"), "UTF-8");
id = new String(resultSet2.getString("id").getBytes("UTF-8"), "UTF-8");
date = new String(resultSet2.getString("date").getBytes("UTF-8"), "UTF-8");
list.add(title2);
list2.add(url2);
list4.add(id);
list5.add(date);
}
when I retrieve something from db, everthing works perfectly. I have also set db to "default character set utf8 default collate utf8_general_ci".
When I write a turkish character with php it saves to db, and I can see that. But when I try to retrieve those turkish characters with my jar it only shows question marks. I tried almost everything but no chance.
Any help is greatly appriciated.
edit: I also changed UTF-8 to ISO-8859-1 in the jar file. But it doesn't work again.