JNDI and c3p0 in Tomcat

Source: Internet
Author: User

In tomcat, JNDI uses the connection pool that comes with Tomcat.
Discard the connection pool that comes with Tomcat. Use c3p0.
Environment: Tomcat 5.5.20
The following configuration is only applicable to Tomcat 5.5.x

The combination of JNDI and c3p0 is as follows:
C3p0: http://nchc.dl.sourceforge.net/sourceforge/c3p0/c3p0-0.9.0.4.bin.zip
Place the c3p0-0.9.0.4.jar under the WEB-INF/lib directory of the Application Service. Such as: dbtest/WEB-INF/lib
1. Add in server. xml. Complete example:

2. Add in Web. xml:

DB connection
JDBC/connpool
Javax. SQL. datasource
Container

3. Test page testconnpool. jsp
<% @ Page Language = "Java" pageencoding = "UTF-8" %>
<% @ Taglib uri = "http://java.sun.com/jsp/jstl/ SQL" prefix = "SQL" %>
<% @ Taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "C" %>

Select ID, typename from text

DB test conn pool c3p0 and JNDI

Results

ID: $ {row. ID}
Name: $ {row. typename}

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.