bonjour,
j'espère bien que vous m'aider mes amis et merci d'avance.
tout d'abord j’éclaire l'environnement logiciel:
ma base donnée est MYSQLet j’utilise MYEclipse 10 et j'ai intégré les frameworks struts et hibernate
j'ai ajouté une methode qui test le Login et le password findByLoginAddPwd(String login,String pwd)à la classe UserDAO.java qui est déjà généré automatiquement avec myeclipse mais j'ai un erreur de developpement, veuillez bien m'aider merci
voisi le code de UserDAO.java
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
package com.load.hibernate;
 
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
 
public class UserDAO extends BaseHibernateDAO  {
		 private static final Log log = LogFactory.getLog(UserDAO.class);
		//property constants
	public static final String IP_USER = "ipUser";
	public static final String NOM_USER = "nomUser";
	public static final String PRENOM_USER = "prenomUser";
	public static final String EMAIL = "email";
	public static final String LOGIN = "login";
	public static final String PASSWORD = "password";
 
 
    public void save(User transientInstance) {
        log.debug("saving User instance");
        try {
            getSession().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re) {
            log.error("save failed", re);
            throw re;
        }
    }
 
	public void delete(User persistentInstance) {
        log.debug("deleting User instance");
        try {
            getSession().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re) {
            log.error("delete failed", re);
            throw re;
        }
    }
 
    public User findById( java.lang.Integer id) {
        log.debug("getting User instance with id: " + id);
        try {
            User instance = (User) getSession()
                    .get("com.load.hibernate.User", id);
            return instance;
        } catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
    }
 
 
    public List findByExample(User instance) {
        log.debug("finding User instance by example");
        try {
            List results = getSession()
                    .createCriteria("com.load.hibernate.User")
                    .add(Example.create(instance))
            .list();
            log.debug("find by example successful, result size: " + results.size());
            return results;
        } catch (RuntimeException re) {
            log.error("find by example failed", re);
            throw re;
        }
    }    
 
    public List findByProperty(String propertyName, Object value) {
      log.debug("finding User instance with property: " + propertyName
            + ", value: " + value);
      try {
         String queryString = "from User as model where model." 
         						+ propertyName + "= ?";
         Query queryObject = getSession().createQuery(queryString);
		 queryObject.setParameter(0, value);
		 return queryObject.list();
      } catch (RuntimeException re) {
         log.error("find by property name failed", re);
         throw re;
      }
	}
 
	public List findByIpUser(Object ipUser
	) {
		return findByProperty(IP_USER, ipUser
		);
	}
 
	public List findByNomUser(Object nomUser
	) {
		return findByProperty(NOM_USER, nomUser
		);
	}
 
	public List findByPrenomUser(Object prenomUser
	) {
		return findByProperty(PRENOM_USER, prenomUser
		);
	}
 
	public List findByEmail(Object email
	) {
		return findByProperty(EMAIL, email
		);
	}
 
	public List findByLogin(Object login
	) {
		return findByProperty(LOGIN, login
		);
	}
 
	public List findByPassword(Object password
	) {
		return findByProperty(PASSWORD, password
		);
	}
	public List findAll() {
		log.debug("finding all User instances");
		try {
			String queryString = "from User";
	         Query queryObject = getSession().createQuery(queryString);
			 return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	 public List findByLoginAddPwd(String login,String pwd){   
	      log.debug("finding by login and password");   
      try {   
	          String queryString = "from User as user where user.login="+login+",user.password="+pwd;   
	          Query queryObject = getSession().createQuery(queryString);   
	          queryObject.setParameter(0, login);   
	          queryObject.setParameter(1, pwd);   
	          return queryObject.list();   
	      } catch (RuntimeException re) {   
	          log.error("find all failed", re);   
	          throw re;   
	      } 
	 }
    public User merge(User detachedInstance) {
        log.debug("merging User instance");
        try {
            User result = (User) getSession()
                    .merge(detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }
 
    public void attachDirty(User instance) {
        log.debug("attaching dirty User instance");
        try {
            getSession().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
 
    public void attachClean(User instance) {
        log.debug("attaching clean User instance");
        try {
            getSession().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
}
l'erreur
javax.servlet.ServletException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: , near line 1, column 60 [from com.load.hibernate.User as user where user.login=admin,user.password=admin]
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


cause mère


et la classe AuthentificationAction
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
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.load.struts.action;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
 
import com.load.hibernate.User;
import com.load.hibernate.UserDAO;
import com.load.struts.form.AuthentifForm;
import java.util.List;
 
public class AuthentifAction extends Action {
 
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		AuthentifForm authentifForm = (AuthentifForm) form;// TODO Auto-generated method stub
		String map="ko";
		String login=authentifForm.getLogin();
		String password = authentifForm.getPassword();
		List test ;
		UserDAO dao =new UserDAO();
		test= dao.findByLoginAddPwd(login, password);
		System.out.println("test size  = "+test.size());
		if(test.size()!=0)
		{System.out.println("utilisateur authentifié");
			map="ok";}
		return mapping.findForward(map);
	}
}