这是 jFrame 按钮上的编码,一个简单的登录表单,用户名和密码验证工作正常,但如果其他条件不执行,如果你们中的任何人在这里帮助我,请给我一个提示
String u_id=jTextField1.getText();
String p_word=jPasswordField1.getText();
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433; databaseName=LoginForm; user=sa; password=aptech");
Statement st=con.createStatement();
ResultSet result=st.executeQuery("select pass_word from employee where user_name='"+u_id+"' ");
if(result.next())
{
String pwd = result.getString("pass_word");
if( p_word.equals(pwd))
{
jLabel4.setText("you are logged in");
}
else if (!p_word.equals(pwd))
{
jLabel4.setText("Your id password is Wrong");
}
}
else
{
jLabel4.setText("Enter your id password again");
jTextField1.setText("");
jPasswordField1.setText("");
}
}
catch (ClassNotFoundException a)
{
System.out.println(""+a);
}
catch (SQLException s)
{
System.out.println(""+s);
}