
import java.sql.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import org.apache.struts.action.*;

public class TestAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        DataSource dataSource = this.getDataSource(request,
                Constant.DATASOURCE_KEY);
        //如果是单数据源,直接DataSource dataSource=this.getDataSource(request );
        Connection connection = dataSource.getConnection();
        HelpOperate helpBean = new HelpOperate();
        UserBean user = helpBean.getUser(connection);
        if (user == null)
            throw new TestException("user is null");
        request.setAttribute("user", user);
        return mapping.findForward("success");
    }

}

