我无法从phpmyadmin本地主机数据库访问用户电子邮件和密码这是我的登录按钮代码
private void jButton2LoginActionPerformed(java.awt.event.ActionEvent evt) {
Connection con=myConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try {
//Selecting UserName and Password From DataBase
ps =con.prepareStatement("SELECT `userName`,` Password` FROM
`user` WHERE `userName` = ? AND `password`= ? ");
ps.setString(1, jTextFieldUserName.getText());
ps.setString(2,String.valueOf( jPasswordField1.getPassword()));
rs=ps.executeQuery();
if(rs.next()){
MyContactForm mcf=new MyContactForm();
mcf.setVisible(true);
mcf.pack();
mcf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mcf.jLabel2UserName.setText(rs.getString(1));
this.dispose();
}else{
JOptionPane.showMessageDialog(null,"Login Error");
}
} catch (SQLException ex) {
System.out.println(" Error");
Logger.getLogger(LoginForm.class.getName()).log(Level.SEVERE, null, ex);
}
}
错误:2018年12月27日中午12:54:00 front.loginform jbutton2loginactionperformed
严重:空
com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception:未知列'
“字段列表”中的“密码”
1条答案
按热度按时间zsohkypk1#
查询中密码前的额外空格。