![](/img/trans.png)
[英]com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'GO'
[英]com.microsoft.sqlserver.jdbc.SQLServerexception:incorrect syntax near'='
我猜第一行出现错误! 请帮我解决它。 我基本上是想通过前端执行查询
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);
}
您的SQL缺少WHERE
关键字。 尝试以下尺寸:
ResultSet rs=st.executeQuery("select * from Login WHERE Username ='"+username+"' and Password= '"+password+"'");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.