初始化Web容器时加载Servlet时加载server.xml里的数据源和

来源:互联网 发布:php帮助手册下载 编辑:程序博客网 时间:2024/06/05 04:17
 jndi模式的 server.xml里的数据源:

  <Context path="/core" docBase="D:\hssoft\hsUnion\HSSMP\core" reloadable="true">
        <Resource name="jdbc/union" auth="Container" type="javax.sql.DataSource" 
driverClassName="dm.jdbc.driver.DmDriver" url="jdbc:DM://127.0.0.1:5236" 
username="SYSDBA" password="SYSDBA" maxActive="100" maxIdle="30" maxWait="10000" />
  </Context>


public class TestServlet extends HttpServlet {
 
    private static final long serialVersionUID = -8756437098790424507L;
    private final static String SERVER_CONFIG = "/conf/server.xml";
 
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request, response);
    }
     
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String config = System.getProperty("catalina.home") + SERVER_CONFIG;
        String jdbcName="union";
           
    }
     
    
}
0 0
原创粉丝点击