if(evt.getSource().equals(btLogin)){
try{
datacon = StarConnection.getConnection();
String str = "select * from management where name='"+txtId.getText()+"' and password='"+txtPass.getText()+"'";
pstat = datacon.prepareStatement(str);
pstat.setString(1, txtId.getText());
pstat.setString(2,txtPass.getText());
rs = pstat.executeQuery();
if(rs.next()){
txtId.setText("");
txtPass.setText("");
JOptionPane.showMessageDialog(null,"登陆成功!");
this.setVisible(false);
}
else
{
JOptionPane.showMessageDialog(null,"用户名或密码有错误!");
}
}catch(Exception e){
e.printStackTrace();
}
}
}
}
String str = "select * from management where name='"+txtId.getText()+"' and password='"+txtPass.getText()+"'";
pstat = datacon.prepareStatement(str);
pstat.setString(1, txtId.getText());
pstat.setString(2,txtPass.getText());
这里冲突了
追问改了 还是不行!您的意思是怎么改呢?
追答String str = "select * from management where name='"+txtId.getText()+"' and password='"+txtPass.getText()+"'";这个改为
String str = "select * from management where name=? and password=?";其他不动追问不行 改了还是问题 控制台现实数据库已连接,但是跳转不了界面