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
|
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;
String requete1 = "INSERT INTO personne (`nom`,`prenom`,`dateNaissance`,`adresse`,`telephone`) VALUES ('"
+ formulaire.getNom()
+ "','"
+ formulaire.getPrenom()
+ "','"
+ formulaire.getDateNaissance()
+ formulaire.getAdresse()
+ formulaire.getTelephone()
+ "')";
instruction.executeUpdate(requete1);
instruction.close();
connexion.close();
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("echec pilote : " + e.toString());
}
}
return mapping.findForward("success");
}
} |
Partager