Hi, as the title said, I have a problem between java and mysql
The mysql DB, tables, and columns are utf8_unicode_ci. I have an application that took some input from an xml, then compose the query...
public String [] saveField(String xmltag, String lang){
NodeList nodo = this.doc.getElementsByTagName(xmltag);
String [] pos = new String[nodo.getLength()];
for (int i = 0 ; i < nodo.getLength() ; i++ ) {
Node child = nodo.item(i);
pos[i] = "INSERT INTO table (id, lang, value) VALUES (" +
child.getAttributes().getNamedItem("id").getNodeValue().toString() + " , " +
lang + " , " +
"'" + child.getFirstChild().getTextContent() + "'" +
");";
}
return pos;
}
this method return an array of String that contains one or more SQL insert Query... then
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///dbname", "user", "pass");
.....
Statement s; s =
this.con.createStatement ();
s.execute(query);
both with s.execyte
and s.executeUpdate
the special characters are stored as ?
so special char are not stored correctly:
מסירות קצרות
is stored as ?????????
Hi!
is stored as Hi!
Any advice?
Thanks