I am trying to read chinese character (for example: 早上好) from a MySQL DB hosted on the server.
The session variables on the server side looked like this
SHOW SESSION VARIABLES LIKE 'char%';
+--------------------------+----------------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | folder/charsets/ |
+--------------------------+----------------------------------------+
I couldn't set the variables through hibernate.cfg file but i did try to set them using the following code. Still didn't work. Tried to set the session variables by directly executing query
Session session = sessionFactory.openSession();
session.beginTransaction();
SQLQuery setQuery1 = session.createSQLQuery("set character_set_client=?;");
setQuery1.setParameter(0, "latin1");
setQuery1.executeUpdate();
After the changes, the same query (SHOW SESSION VARIABLES LIKE 'char%';) when i run through hibernate (with the same connection) is displaying the expected values for the SESSION VARIABLES. However, the result of the query to display the chinese character seems corrupted or unreadable (somewhat like "阿ç´ç’°ç¤")