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
|
Ca donnerait :
public ActionForward save(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
Connection connection = MyPoolConnection.getConnection();
// Appel des DAO
myDAO.setConnection(connection);
//
return mapping.....
}
catch(SQLException e) {
// Erreur => Rollback de la connection
connection.rollback();
}
finally {
// Fermeture de la connection
try {
if (connection != null) {
// Fermeture de la connection
connection.close();
}
}
catch(SQLException e) {}
}
return mapping.....ERROR
} |
Partager