When i'm trying to find record by hebrew field it doesn't return any data when executing my query. Despite the fact that when i am pasting the same query in my wampserver the query return the rights answer!
I define the table and the fields as utf8_general_ci
and still the problem occurred. please help.
public ArrayList<String> findPartnersFast(String semester , String course , String city) {
String currentQuery = "SELECT * FROM fast_reg " + "WHERE course = " + "'" + "מבוא למקרוכלכלה" + "'" ;
ArrayList<String> arrayOfResults = new ArrayList<String>();
try {
statement = connection.createStatement();
res = statement.executeQuery(currentQuery);
Log.d("DBmanipulation" , currentQuery);
while(res.next()) {
Log.d("DBmanipulation" , "in while loop!");
String temp = res.getString("student_name");
arrayOfResults.add(temp);
Log.d("DBmanipulation", "name: " + temp);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (res != null) {
res.close();
}
} catch (Exception e) {
}
}
return arrayOfResults;
}
LOG:
03-20 20:29:09.400 3593-4082/com.example.uvalerx073037.finalproject_correct D/Register: In BackGround
03-20 20:29:09.400 3593-4082/com.example.uvalerx073037.finalproject_correct I/System.out: conneting to Database...
03-20 20:29:09.532 3593-4082/com.example.uvalerx073037.finalproject_correct I/System.out: Connection Successful
03-20 20:29:09.550 3593-4082/com.example.uvalerx073037.finalproject_correct D/DBmanipulation: SELECT * FROM fast_reg WHERE course = 'מבוא למקרוכלכלה'
03-20 20:29:09.557 3593-4082/com.example.uvalerx073037.finalproject_correct I/System.out: connection close properly
You need to make sure that sql table row and field encoded correctly:
take a look at this answer also: MySQL db question marks instead of hebrew characters..?