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

public class DataSourceAction extends Action
{

    public DataSourceAction()
    {
    }

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws Exception
    {
        DataSource dataSource = null;
        Connection cnn = null;
        try
        {
            dataSource = getDataSource(request);
            cnn = dataSource.getConnection();
        }
        catch(SQLException e)
        {
            getServlet().log("处理数据库连接", e);
        }
        finally
        {
            try
            {
                cnn.close();
            }
            catch(SQLException e)
            {
                getServlet().log("关闭数据库连接", e);
            }
        }
        return mapping.findForward("success");
    }
}