TOMCAT8 Configuring ORACLE11G Data sources

Source: Internet
Author: User
Tags auth

1:context.xml

<resourcename= "Jdbcoracle"  auth= "Container" type= "Javax.sql.DataSource" factory= " Org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory "maxactive=" "maxidle=" 1 "maxwait=" username= "Yshy" Password= "Yshy" driverclassname= "Oracle.jdbc.OracleDriver" url= "Jdbc:oracle:thin: @localhost: 1521:xe"/>

2:web.xml

<resource-ref>        <description>oracle database connection pool </description>        <res-ref-name> jdbcoracle</res-ref-name>        <res-type>javax.sql.DataSource</res-type>        <res-auth> Container</res-auth>    </resource-ref>

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 ("Data source test Join succeeded:" +conn);        } catch (Namingexception | SQLException ex) {            Logger.getlogger (TestServlet.class.getName ()). log (Level.severe, NULL, ex);        }            }

  

 

TOMCAT8 Configuring ORACLE11G Data sources

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.