Hi, currently I have something like the code below on every action, is
this the normal way of getting the connection?  And how would normal
people do if they want to make some data access objects, which contain
all the methods like insert, select etc, while the Action class will
purely do logic, for example only contain this kind of statements:
HashMap hmResult = dataAccess.getAllClients();  Thanks.

    public ActionForward perform(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
        ServletContext context = servlet.getServletContext();
        try {
            DataSource dataSource =
(DataSource)context.getAttribute(Action.DATA_SOURCE_KEY);
            Connection conn = dataSource.getConnection();
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * FROM aTable");
            while(rs.next()) {
                //...
            }
            
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (mapping.findForward("xxx"));
        }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to