private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{
String CompanyID=ComID.getText();
String User_name=Username.getText();
String password=Password.getText();
String post_held=jTextField2.getText();
String azu="update staffs set StaffID=
'"+CompanyID+"',UserName='"+User_name+"',Password='"+password+"','Post_held="+post_held+"'where StaffID='"+CompanyID+"' ";
//azucar="update staffs set StaffID= ?,?,?,?";
az.psst = az.conn.prepareStatement(azu);
az.psst.execute(azu);
JOptionPane.showMessageDialog(null,
"Updated!","Frsc",JOptionPane.INFORMATION_MESSAGE);
}catch (Exception e){
JOptionPane.showMessageDialog(null, e);
}deb();
}
列出项目
答案 0 :(得分:0)
'Post_held="+post_held+"'where
应该是
Post_held='"+post_held+"' where
。
另一方面说明:不要使用字符串连接构建SQL语句,或者让自己对SQL Injection攻击开放,这将允许攻击者删除/窃取所有人数据
使用带有参数标记的PreparedStatement
(?
)并在语句对象上设置值。