Hi,
The online help says that the number of "used jdbc connections" is
the number of opened sql transactions; and that in the case where
there is no datasource, it is in fact the number of opened jdbc
connections in the connection pool.
And it also says that the number of "active jdbc connections" is the
number of current sql requests.
In general, jdbc connections come from a jdbc datasource. The jdbc
datasource is configured in your application server and is available
in JNDI. In your application, you get the datasource instance with a
JNDI lookup.
When you want to use a jdbc connection for a transaction, you call
"dataSource.getConnection()" to get the connection and then you call
"connection.close()" on this jdbc connection at the end of the
transaction (after commit or rollback of course). In fact, the
"connection.close()" method does not close the socket to the
database, it just says that the connection is released by the
application to be kept opened in the connection pool inside the
datasource (and later, the connection can be reused for another
transaction).
Note: Often the "dataSource.getConnection()" and the
"connection.close()" methods are not called directly by your
application but they are called by some framework such as JavaEE,
Spring or Hibernate.
It may happen that your jdbc datasource is not configured in your
application and is not in JNDI, but that it is configured in Spring
for example, in which case only the lookup is different.
The javamelody UserGuide says how to monitor the jdbc connections
for this datasource in both cases.
When you use a jdbc datasource and if it is correctly monitored, the
"used jdbc connections" value in javamelody is the number of
connections for which the getConnection() method has been called and
the close() method has not yet been called.
The "used jdbc connections" is supposed to be between 0 and the max
of jdbc connections as configured in the datasource ("maxActive" in
the standard Tomcat datasource, "max-pool-size" in the Glassfish
connection pool)
And the number of "active jdbc connections" is the number of
connections for which an executeXxx method has been called on a
statement of the connections and that executeXxx has not yet ended.
The current number of "active jdbc connections" is supposed to be
between 0 and the current number of "used jdbc connections".
Finally and I do not recommend that, some applications don't use a
datasource from JNDI and neither a datasource from Spring, in which
case there is often a connection pool configured directly in the
application. And so the close() method is not called at the end of
each transaction because connections are kept opened by the
application inside its connection pool.
And as said in the online help, when there is no datasource, "used
jdbc connections" is in fact the number of opened jdbc connections
in this connection pool.
The javamelody UserGuide says how to configure the jdbc driver in
order to monitor jdbc connections in this case.
So if the "used jdbc connections" has an increase in your
application, it may mean that:
- the javamelody monitoring for jdbc is not well configured in your
application
- or your current jdbc setup is not supported by javamelody or
javamelody has a bug
- or perhaps your application has a resource leak
Anyway, 3000 jdbc connections seems way too much to me.
I suggest to do a quick check from the database point of view, and
to ask the database with a native client how many connections are
opened (by all computers).
If oracle, execute "select * from v$session"
If H2, execute "select * from information_schema.sessions"
If mysql, execute "show full processlist"
etc
bye,
Emeric