Hello all,
I have a mysql-database. In this database, there are several tables, which are created as latin-tables. But the tables contains utf8-strings. I can't covert the tables. My problem now starts, if I try to use JDBC for an SELECT-query with an unicode-charachter.
Example:
public static void main(String[] args) throws SQLException, UnsupportedEncodingException
{
MySQL mysql = null;
Statement stmt = null;
ResultSet rs = null;
String query = "";
mysql = new MySQL(new File("/home/dab/.my.cnf.ts"), "localhost", "UTF8");
stmt = mysql.getStatement();
query = "SELECT user_id" + " " +
"FROM dewiki_p.user " +
"WHERE user_name = \"Johannis Gro�\";";
rs = stmt.executeQuery(query);
while (rs.next())
{
System.out.println(rs.getString(1));
}
}
This returns nothing. If I use a non-unicode-word like "Test", I get a result. If I let my testprogramm output the query-string and copy/paste it to the mysql-command-line-programm, I get a result too. If I change my query in that way, that it runs very long and look for the query in mytop, I see that JBDC changed the query and the � is shown as �.
There connection-url for the example above is:
jdbc:mysql://localhost:3306/?user=dab&password=XXXX&useUnicode=false&characterEncoding=UTF8&characterSetResults=UTF8
I tried the example with ISO8859_1 too.
I guess the problem is, that JDBC trys to correct my query and that fails.
Have anyone a idea?
Sincerly,
DaB.
P.S: Sorry for my bad english.