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}