private void signoutbutton1ActionPerformed(java.awt.event.ActionEvent evt) {
String sql = "select * from userlogin where Username=? and Password=? and Hasmac='false' and Blacklisted='false' and Level='student' or Level='teacher' or Level='admin'";
try {
String value6 = txt_sou.getText();
pst = conn.prepareStatement(sql);
pst.setString(1, txt_sou.getText());
pst.setString(2, signoutpassword.getText());
rs = pst.executeQuery();
if (rs.next()) {
//this sql query will not run//
sql = "update userlogin set Hasmac='true' where username='" + value6 + "'";
//yet this runs//
this.dispose();
{
}
} else {
errorsignout.setText("Error: User Information Not Found");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
答案 0 :(得分:0)
sql
的第二个赋值只是改变了该字符串变量的值。
要执行SQL语句,您必须调用prepareStatement
来获取语句对象,并在其上调用executeUpdate
。