Java SQLite准备的语句错误:java.sql.SQLFeatureNotSupportedException

时间:2018-10-10 10:14:04

标签: java sqlite

我正在尝试使用SQLite在JAVA中执行准备好的语句。我可以通过给我一个用户名和密码正确的消息来建立良好的连接并验证第一条语句。出现此错误后:

java.sql.SQLFeatureNotSupportedException

经过一番阅读,我看到有人说这通常发生在将语句放回到executeQuery()函数中时。显然我还没有这样做。任何帮助表示赞赏。

代码如下:

 private void cmd_loginActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        //sql query
        String sql ="select * from users where username =? and password=?";
        String statussql = "select status from users where username=?";

        try{
                    pst=conn.prepareStatement (sql);  
                    pst.setString(1,txt_username.getText());
                    pst.setString(2,txt_password.getText());
                    rs=pst.executeQuery();
                    //if the input from user is correct the data is brought to the result set
                    if (rs.next()){
                        JOptionPane.showMessageDialog(null,"username and password is correct");
                    //Home ob =new Home();
                    //ob.setVisible(true);
                        try{

                    pst=conn.prepareStatement (statussql);  
                    pst.setString(1,txt_username.getText());

                    rs=pst.executeQuery();

                    if (rs.next()){


                    String userstatus = rs.getObject(1, String.class);


                        if(userstatus.equals("admin")){

                            Home ob =new Home();
                            ob.setVisible(true);
                            dispose();

                        }else{
                            User nu =new User();
                            nu.setVisible(true);
                            dispose();

                        }
                    }
                    else{
                    JOptionPane.showMessageDialog(null,"username and password is not correct");
                    }
        }
        catch(SQLException e)
        { 
            JOptionPane.showMessageDialog(null,e);
                    }
                    }
                    else{
                    JOptionPane.showMessageDialog(null,"username and password is not correct");
                    }
        }
        catch(SQLException e)
        { 
            JOptionPane.showMessageDialog(null,e);
                    }

    }                   

0 个答案:

没有答案