-1
我需要在更新sql時指定列名。 始終得到像下面的錯誤信息(使用=?):java mysql指定列總是錯誤
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL
syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near ''d11'=1 where cityid=11143'
at line 1
代碼片段
conn.setAutoCommit(false);
pstmt = conn.prepareStatement("update usercityday set ?=? where cityid=?");
for (int i = 1; i < 91727; i++) {
for (int j = 1; j < 32; j++){
if (map[i][j] != 0){
pstmt.clearParameters();
pstmt.setString(1, "d" + String.valueOf(j));
pstmt.setInt(2, map[i][j]);
pstmt.setInt(3, i);
pstmt.executeUpdate();
ic++;
if (ic %1000 == 0) {
conn.commit();
}
}
}
}
好的。我明白了,謝謝。 – ken