Basically I have Column row with the value of:
ID Title
----- ----------------------------------
| 1 |ماهر زين - عليك صلى الله (Official) |
----- ----------------------------------
-
String Title = null;
DBConnect Database = new DBConnect();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
try{
con = Database.getcon();
String query2="SELECT TITLE FROM table WHERE ID=?";
ps = con.prepareStatement(query2);
ps.setInt(1, 1);
rs=ps.executeQuery();
if(rs.next()){
Title=rs.getString(1);
System.out.println(Title);
}
} finally {
if(ps != null)
ps.close();
if(rs != null)
rs.close();
if(con != null)
con.close();
}
To connect to the DB I Do:
public DBConnect(){
try{
Class.forName("com.mysql.jdbc.Driver");
String unicode="useSSL=false&useUnicode=yes&characterEncoding=UTF-8";
con = DriverManager.getConnection("jdbc:mysql://localhost:15501/db?"+unicode, "root", "pwd");
st = con.createStatement();
}catch(Exception ex){
System.out.println(ex.getMessage());
System.out.println("couldn't connect!");
}
}
But the Output I get is: ????? ??? ????? ? ??? ?? ????? (Official)
I also have tried:
ALTER DATABASE <name> CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE <table_name> CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
- I also tried:
select
c.character_set_name
from information_schema.tables as t,
information_schema.collation_character_set_applicability as c
where c.collation_name = t.table_collation
and t.table_schema = "duckdb"
and t.table_name = "stackscontents";
The output I get is `utf8mb4
FYI: My my.ini
file says default-character-set=utf8
Yet still i'm getting the output as: ????? ??? ????? ? ??? ?? ????? (Official)
All replies are much appreciated