【发布时间】:2013-11-18 14:18:30
【问题描述】:
我正在尝试更新 MS Access 数据库。我已经对此进行了搜索,并尝试了所有找到的方法,但仍然出现以下错误。
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] UPDATE 语句中的语法错误。
任何帮助都会非常有帮助。我的代码在下面……;
String sqlStatement = "UPDATE ProductCatalogue"
+ "SET [StockLevel] = ?"
+ "WHERE [ProductID] = ?;";
PreparedStatement prepStatement = connection.prepareStatement(sqlStatement);
prepStatement.setInt(1, quantity);
prepStatement.setInt(2, productID);
//= "UPDATE ProductCatalogue"
//+ "SET StockLevel = " + quantity
//+ "WHERE ProductID = " + productID + ";";
try {
//myStatement.executeUpdate(sqlStatement);
prepStatement.executeUpdate();
} catch (SQLException sqle) {
System.out.println("Oopss...." + sqle);
}
connection.close();
prepStatement.close();
【问题讨论】: