Advertisement
evgheni

Use connection class

Jan 27th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. import java.sql.Connection;
  2.  
  3. public class MailItemAction extends MyAction{
  4.  
  5.   public static Logger logger = Logger.getLogger(MailItemAction.class);
  6.  
  7.   public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
  8.         logger.debug("execute");
  9.         Connection conn = null;
  10.          try {
  11.             conn = ConnectionFactory.getConnection(dataSourceName);
  12.             MailItemForm myForm = (MailItemForm)form;
  13.         }catch (Exception e) {
  14.             logger.info("errore " + e.getMessage());
  15.         }finally {
  16.             try {
  17.                 conn.close();
  18.              } catch (Exception e) {
  19.                 throw new ServletException(e.getMessage());
  20.             }
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement