我有一個問題,如this post。我正在使用netbeans 7.01 IDE和MySQL 5.2.35。我用這個技巧,但不是有效的: 我加在我的配置文件,這個屬性:由netbeans Hibernate Unicode;爲什麼在db中保存爲「?????」
<property name="hibernate.connection.useUnicode">true</property>
<property name="hibernate.connection.characterEncoding">UTF-8</property>
也:
的jdbc:mysql的://本地主機:3307/MY_DB_NAME了useUnicode =真& characterEncoding = UTF-8
但無效!
也是我試過這個Java代碼來使Java字符串Unicode和也實在是徒勞的:
public static String toUTF8(String isoString) {
String utf8String = null;
if (null != isoString && !isoString.equals("")) {
try {
byte[] stringBytesISO = isoString.getBytes("ISO-8859-1");
utf8String = new String(stringBytesISO, "UTF-8");
} catch (UnsupportedEncodingException e) {
System.out.println("UnsupportedEncodingException is: " + e.getMessage());
utf8String = isoString;
}
} else {
utf8String = isoString;
}
return utf8String;
}
任何一個能幫助我嗎?!
我已經在之前將它設置爲utf8默認集合。我也嘗試將其設置爲DEFAULT COLLATE utf8_general_ci。無效! – sajad