登录信息的验证

public void yanzheng(String a, String b) {
		try {
			conn = getConnection();
			String sql = "select * from master where name = ? and password = ?";
			stmt = conn.prepareStatement(sql);
			stmt.setString(1, a);
			stmt.setString(2,b);
			rst = stmt.executeQuery();
			if(rst.next()) {
				user = rst.getString(1);
				pwd = rst.getString(2);
				JOptionPane.showMessageDialog(null, 
						"登录成功!!!",
						"提示消息", 
						JOptionPane.WARNING_MESSAGE);
				//new zhujiemian();
			}else {
				JOptionPane.showMessageDialog(null, 
						"用户名或密码错误!!!",
						"提示消息", 
						JOptionPane.ERROR_MESSAGE);
				
			}
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			closeAll();
		}
		
	}
	

 

你可能感兴趣的:(登入注册信息的验证)