java - Apache DBCP2 connection pool open more MYSQL connection than maxTotal on Tomcat startup -
i have configured apache dbcp2 jndi datasource in apache tomcat 8.5.16. resource tag in context.xml looks below.
<resource auth="container"     type="javax.sql.datasource"      driverclassname="com.mysql.cj.jdbc.driver"     url="jdbc:mysql://localhost:3306/mydb?autoreconnect=true&usessl=false"     username="root"     password="mypassword"     name="jdbc/myds"     initialsize="5"     minidle="5"      maxidle="10"     maxtotal="20"     testoncreate="true"     testonborrow="true"      testonreturn="true"     testwhileidle="true"     validationquery="select 1 dual"     validationquerytimeout="60"     timebetweenevictionrunsmillis="180000"     numtestsperevictionrun="10"     softminevictableidletimemillis="150000"     maxconnlifetimemillis="300000"     logabandoned="true"     removeabandonedonborrow="true"     removeabandonedonmaintenance="true"      removeabandonedtimeout="60"     maxwaitmillis="60000" /> my questions are:
- i started tomcat (i haven't deployed application on tomcat yet). opened mysql client terminal, logged in root. when run command show processlist, seeing 31 connections. 1 mysql client terminal , 30 tomcat. why dbcp2 has acquired 30 connections when maxtotal 20? no, 1 else using mysql other tomcat , mysql client terminal.
- since haven't deployed application on tomcat use jndi datasource connections dbcp2 idle. timebetweenevictionrunsmillis="180000" not removing these idle connections.
- when remove minidle="5". after 180000 millis 30 mysql connections gets removed connection pool , connection pool size becomes zero.
help me understand behavior. advance.
sorry everyone. it's mistake in understanding. tomcat 8.5.16 using has 6 applications in webapps directory(root, docs, examples, host-manager, manager, etc). since, created apache dbcp2 jndi datasource in context.xml in tomcat's conf directory, tomcat has created 6 connection pools having initialsize="5" each application in webapps directory. need revisit jndi datasource configuration can restrict used 1 application.
 passing by.    
Comments
Post a Comment