1:context.xml
2:web.xml
Oracle 数据库连接池 jdbcoracle javax.sql.DataSource Container
3:TestServlet.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { InitialContext ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbcoracle"); Connection conn = ds.getConnection(); out.print("数据源测试联接成功:"+conn); } catch (NamingException | SQLException ex) { Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex); } }