我目前正在计算值以填充 1500 万条记录的数据库。第一个 7 磨机刚刚好,但是现在我的更新查询开始出现问题:现在 & 然后一个随机字母变成了一些乱码。在java中,我生成查询:
String updateSql = "UPDATE VanNaar SET time = CASE ID ";
for (int i = 0; i < routes.size(); i++) {
updateSql += " WHEN " + routes.get(i).ID + " THEN " + routes.get(i).driveTime;
}
updateSql += " END, ";
updateSql += " distance = CASE ID ";
for (int i = 0; i < routes.size(); i++) {
updateSql += " WHEN " + routes.get(i).ID + " THEN " + routes.get(i).distance;
}
updateSql += " END WHERE id IN (";
for (int i = 0; i < routes.size(); i++) {
updateSql += routes.get(i).ID + ",";
}
updateSql = updateSql.substring(0, updateSql.length() - 1);
updateSql += ");";
如前所述,效果很好。以下是 Java 现在向我提出的问题:
...MySQL server version for the right syntax to use near '×HEN 8284022 THEN 999.999 WHEN 8284023 THEN 3791.0 WHEN 8284024 THEN 378...
或者
...MySQL server version for the right syntax to use near 'WÈEN 7468574 THEN 2273.0 WHEN 7468575 THEN 2410.0 WHEN 7468576 THEN 2472.0 W' at line 1
注意奇怪的Ã^或Ã-,最后一个例子,请注意大胆的 tekst:
...MySQL server version for the right syntax to use near **'Â** WHEN 7228125 THEN 48590.0 WHEN 7228126 THEN 47910.0 WHEN 7228127 THEN...
...
更新:似乎变得更糟了..:
Unknown column '9°22331' in 'where clause'