[英]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.