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
|
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
HttpSession session = request.getSession();
try {
Class.forName(pilote);
Connection connexion = DriverManager.getConnection(
"jdbc:mysql://localhost/personne", "root", "");
Statement instruction = connexion.createStatement();
PersonneForm formulaire = (PersonneForm) form;
Personne personne = new Personne(formulaire.getNom(), formulaire
.getPrenom(), formulaire.getDateNaissance(), formulaire
.getAdresse(), formulaire.getTelephone());
for (Iterator iter = listdn.iterator(); iter.hasNext();) {
Personne element = (Personne) iter.next();
String requete1 = "INSERT INTO perssonne (`nom` , `prenom` , `dateNaissance` ) VALUES ('"
+ personne.getNom()
+ "','"
+ personne.getPrenom()
+ "','"
+ personne.getDateNaissance()
+ personne.getAdresse()
+ personne.getTelephone()
+ "')";
instruction.executeUpdate(requete1);
}
session.setAttribute("listdn", listdn);
instruction.close();
connexion.close();
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("echec pilote : " + e.toString());
}
}
return mapping.findForward("success");
} |
Partager