The connection pool is configured on tomcat {connect error=name [Jdbc/oracledb] is not bound in the this Context. Unable to find [JDBC]}

Source: Internet
Author: User
Tags connection pooling

. During the learning period, I never practiced the connection pooling on Tomcat, and today I finally realized it once, playing in Tomcat and wondering if you have the same dilemma as me now. Nonsense less say directly on the code Java
public static Connection Getconnection_tomcat () {        Connection conn = null;        try {            Context initctx = new InitialContext ();            Context CTX = (context) initctx.lookup ("java:comp/env");                   Object obj = (object) ctx.lookup ("Jdbc/oracledb");            Javax.sql.DataSource ds = (javax.sql.DataSource) obj;            Return conn = Ds.getconnection ();        }        catch (Exception e) {                       System.out.println ("Connect error=" + e.getmessage ());            return null;        }    }

In Tomcat->conf->server.xml

  <GlobalNamingResources>    <!--Editable User database that can also is used by         Userdatabaserealm to Authen Ticate users--    <resource name= "userdatabase" auth= "Container" type= "              Org.apache.catalina.UserDatabase "              description=" User database that can be updated and saved "              factory=" Org.apache.catalina.users.MemoryUserDatabaseFactory "              pathname=" Conf/tomcat-users.xml "/><!--in Tomcat Configure connection pooling-  <resource name= "jdbc/oracledb"  auth= "Container"                         type= "Javax.sql.DataSource    " Driverclassname= "Oracle.jdbc.driver.OracleDriver"      url= "    maxactive=" "      maxldle=      " maxwait= "Username=" "password=" "    />    </GlobalNamingResources>

In Tomcat->conf->context.xml

<Context>    <WatchedResource>WEB-INF/web.xml</WatchedResource><!--Configuring a connection pool-->< ResourceLink global= "Jdbc/oracledb" name= "Jdbc/oracledb" type= "Javax.sql.DataSource"/>  </Context>

That's it!

The connection pool is configured on tomcat {connect error=name [Jdbc/oracledb] is not bound in the this Context. Unable to find [JDBC]}

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.