salut

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
package com.intervention.jsf.dao;
 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
 
 
import com.intervention.jsf.util.DbConn;
 
public class LoginDAO {
 
	public static String validate(String user, String password) throws SQLException {
		Connection con = null;
		PreparedStatement ps = null;
		String type="Undefined";
			con = DbConn.connexion();
			ps = con.prepareStatement("Select LOGIN, PASSWORD,type from INTERVENANT where LOGIN = ? and PASSWORD = ?");
			ps.setString(1, user);
			ps.setString(2, password);
		    ResultSet rs = ps.executeQuery();
 
			if (rs.next()) {
				type=rs.getString(3);
				return type;
			}
			// hna mli makaykonch chi user type tatkon null att nchofo blan
			if(type == "Undefined")
 
 
			return "fail";
 
 
 
 
 
			return type;	
 
			}
 
 
}
et

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
	public String validateUsernamePassword() throws SQLException {
		String test=null;
		String valid = LoginDAO.validate(login, password);
 
		if (valid.equals("admin")) {
			HttpSession session = SessionBean.getSession();
			session.setAttribute("username", login);
			test="admin";
		} else  if (valid.equals("intervenant")) {
			HttpSession session = SessionBean.getSession();
			session.setAttribute("username", login);
			test= "intervenant";
		}
		else if(valid.equals("false")) {
			HttpSession session = SessionBean.getSession();
			session.setAttribute("username", login);
			test= "fail";
		}
		return test;
l'erreur dis que ca viens de ces deux classes ci-dessus
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
Caused by: java.lang.NullPointerException
	at com.intervention.jsf.dao.LoginDAO.validate(LoginDAO.java:18)
	at com.intervention.jsf.beans.intervenant.validateUsernamePassword(intervenant.java:55)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.sun.el.parser.AstValue.invoke(AstValue.java:289)
	at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
	at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
aider moi svp