第二个SQL查询未运行

时间:2014-04-02 18:31:28

标签: java sqlite

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);

    }
}                                             

1 个答案:

答案 0 :(得分:0)

sql的第二个赋值只是改变了该字符串变量的值。

要执行SQL语句,您必须调用prepareStatement来获取语句对象,并在其上调用executeUpdate

相关问题