[英]com.microsoft.sqlserver.jdbc.SQLServerexception:incorrect syntax near'='
I'm getting the error in the first line i guess! 我猜第一行出现错误! Please help me out in dealing with it.
请帮我解决它。 I'm basically trying to execute a query through my front end
我基本上是想通过前端执行查询
try {
ResultSet rs=st.executeQuery("select *from Login Username ='"+username+"' and Password '"+password+"'");
rs.last();
int counter = rs.getRow();
if (counter==1){
JOptionPane.showMessageDialog(null,"Username and Password Correct","Username and Password Correct",JOptionPane.INFORMATION_MESSAGE);
this.setVisible(false);
new Menu().setVisible(true);
hide();
}else{
jt_username.setText("");
jp_password.setText("");
JOptionPane.showMessageDialog(null,"Error","Username and Password Incorrect",JOptionPane.INFORMATION_MESSAGE);
}
}
catch (SQLException ex) {
JOptionPane.showMessageDialog(null, ex);
}
Your SQL is missing the WHERE
keyword. 您的SQL缺少
WHERE
关键字。 Try this on for size: 尝试以下尺寸:
ResultSet rs=st.executeQuery("select * from Login WHERE Username ='"+username+"' and Password= '"+password+"'");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.