Servlet 3.0 proxool 配置 数据库连接池

Servlet3.0没有配置web.xml  但又要添加数据库连接池。暂时自己想到的办法是新建一个servlet继承ServletConfigurator.

package com.company.servlet;

import java.io.File;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.logicalcobwebs.proxool.ProxoolException;
import org.logicalcobwebs.proxool.configuration.JAXPConfigurator;
import org.logicalcobwebs.proxool.configuration.ServletConfigurator;

/**
 * Servlet implementation class InitServlet
 */
@WebServlet(urlPatterns={"/ServletConfigurator"},loadOnStartup=1,initParams={@WebInitParam(name="xmlFile",value="WEB-INF/proxool.xml")})
public class InitServlet extends ServletConfigurator {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public InitServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	
}

这样就可以数据库连接池就可以加载了。


你可能感兴趣的:(Servlet 3.0 proxool 配置 数据库连接池)