java My netbeans认为输入textfield的值是一个列名,而不是我需要删除的值
private void deleteActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
// String sql = "Delete from tender.bidder where b_id =" + bidtxt.getText();
PreparedStatement pstmt = con.prepareStatement("delete from tender.bidder where bidder.b_id =" + bidtxt.getText());
int i = pstmt.executeUpdate();
System.out.print(i + "record deleted");
con.close();
bidtxt.setText("");
bnametxt.setText("");
officetxt.setText("");
streettxt.setText("");
citytxt.setText("");
statetxt.setText("");
contacttxt.setText("");
passwordtxt.setText("");
emailtxt.setText("");
tidtxt.setText("");
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
selectionall();
}
The error : java.sql.SQLSyntaxErrorException: Column 'B001' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'B001' is not a column in the target table.
# 1 楼答案
您没有正确使用准备好的报表。你可以使用一个
?
来定义你的值。但是,语句中的字符串也缺少所需的引号,这会导致语法错误