获取"java.sql.SQLException: Values not bound to statement"异常
获取"java.sql.SQLException: Values not bound to statement"异常
我试图制作一个程序,其中包含使用SQL连接登录系统的用户,然后如果凭据正确,用户将被重定向到另一个窗口。
但是,我遇到了一个问题,我想在SQL数据库中存储一些信息,所以我尝试使用while循环,它起作用了,但后来遇到了一个错误:
java.sql.SQLException: Values not bound to statement
请参考以下代码:
String pseudo2 = null; String rank2 = null; try { String searchname2 = "select * from AdminsInfos where pseudo=?"; PreparedStatement name2 = connection.prepareStatement(searchname2); ResultSet rspseudo2 = name2.executeQuery();; while (rspseudo2.next()) { pseudo2 = rspseudo2.getString("Pseudo"); rank2 = rspseudo2.getString("Rank"); } } catch (Exception e2) { e2.printStackTrace(); } JOptionPane.showMessageDialog(null, "用户名和密码正确,连接管理员!"); frame.setVisible(false); new LoginMain().setVisible(true); LoginMain.usernameField.setText(pseudo2); LoginMain.ranklabel.setText("等级:" + rank2);
您也可以通过以下图片检查SQL数据库:
有人可以帮帮我吗?