I am having an issue inserting Unicode character into database. The function I have here
public void insertCleanText(String text, String page_id, String text_id) {
// System.out.println("inserting in cleanText: ");
byte cleanText[] = null;
try {
cleanText = text.getBytes("UTF8");
} catch (Exception e) { // UnsupportedEncodedException
e.printStackTrace();
}
try {
// ps = cn.prepareStatement("INSERT INTO cleanText VALUES (null, ?, ?, ?, ?)");
if (cleanText != null) {
psCleanText.setBytes(1, cleanText);
psCleanText.setBoolean(2, false); // it will be true after processed by the FeatureMaker
psCleanText.setInt(3, Integer.parseInt(page_id));
psCleanText.setInt(4, Integer.parseInt(text_id));
psCleanText.execute();
psCleanText.clearParameters();
} else
System.out.println("WARNING: can not insert in " + cleanTextTableName + ": " + text);
} catch (SQLException e) {
e.printStackTrace();
}
}
For example, I want to insert the String "Thực tế" but when I select it in MySQL, it show something like "Th?c t?".
Anybody has an idea to fix this?
Aucun commentaire:
Enregistrer un commentaire