我不斷收到SQL語法錯誤,但我無法理解我在哪裏出錯。任何人都可以將我指向正確的方向嗎?SQLSyntaxError即使使用Prepared Statement
String sql = "INSERT INTO Weights"
+ " (ID, W1, W2, W3, W4, W5)"
+ " VALUES (?, ?, ?, ?, ?, ?)";
PreparedStatement statement = mysqlConnect.connect().prepareStatement(sql);
statement.setString(1, String.valueOf(col-1));
statement.setDouble(2, weights[row][c]);
statement.setDouble(3, weights[row][c]);
statement.setDouble(4, weights[row][c]);
statement.setDouble(5, weights[row][c]);
statement.setDouble(6, weights[row][c]);
statement.execute(sql);
總結鏈接重複:你需要使用'statement.execute()'(或'statement.executeUpdate()')來代替。 –