On one of our environments there is tomcat 8 with following JDBC datasource configuration:
<Resource name="jdbc/mydatasource"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@myhostname:1521:dbname"
username="username"
password="password"
removeAbandoned="false"
removeAbandonedTimeout="300"
logAbandoned="true"
initialSize="5"
maxActive="100"
maxIdle="100"
minIdle="5"
maxWait="120000"
/>
Netstat command returns following results:
netstat -anu | grep ${pid}| grep ESTABLISHED | grep ${myhostname}:1521 | wc -l
55
This result remains stable during several days.
At the same time I monitor tomcat datasource attributes via JMX:
numActive = 0
numIdle = 5
These results also remain stable during several days.
It looks like tomcat creates JDBC connection pool with initial size of 5 connections, keeps amount of idle connections at 5, but for some reasons amount of established connections showed by netstat is 11 times bigger.
When minIdle="5" in context.xml and JMX shows numActive+numIdle=5 netstat should also show 5 established connections, shouldn't it?
I suppose that while sustaining JDBC pool tomcat continuously opens and closes connections to database, which remain in ESTABLISHED state from netstat point of view until being dropped by database.
My question is how to change tomcat datasource configuration to make netstat output consistent with this configuration?
Thank you very much in advance.