gpt4 book ai didi

java - 如何从 MySql PhpMyadmin 本地主机访问用户电子邮件和密码

转载 作者:行者123 更新时间:2023-11-29 16:30:45 25 4
gpt4 key购买 nike

我无法从 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);
}

}

Error Dec 27, 2018 12:54:00 PM Front.LoginForm jButton2LoginActionPerformed

SEVERE: null

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column '

Password' in 'field list'

最佳答案

查询中的密码前有一个额外的空格。

关于java - 如何从 MySql PhpMyadmin 本地主机访问用户电子邮件和密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53941745/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com