2
從2小時起,我正在處理UPDATE TABLE語句,它總是給出語法錯誤。我做了這個:更新表的語法錯誤表
String falseValue = "False";
String emptyValue = "";
try {
OrderListViewerModel orderlistviewermodell = (OrderListViewerModel) tableOrder.getSelectionModel().getSelectedItem();
pst = conn.prepareStatement("UPDATE TABLE productList SET ordered = '" + falseValue + "', orderedshopphone = '" + emptyValue + "' WHERE barcode = " + orderlistviewermodell.getProductBarcode() + "");
pst.executeUpdate();
pst = conn.prepareStatement("DELETE FROM orderList WHERE productbarcode=?");
pst.setString(1, orderlistviewermodell.getProductBarcode());
pst.executeUpdate();
pst.close();
} catch (SQLException ex) {
Logger.getLogger(StoreListViewerController.class.getName()).log(Level.SEVERE, null, ex);
}
的刪除工作正常,但更新不是真的。它說我有語法錯誤並檢查出來。
你已經使用PrepapredStatement你爲什麼不使用'?',以避免SQL注入,或語法注射 –