aspose file tools
The moose likes JDBC and the fly likes Finding the number of active database connections Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Finding the number of active database connections" Watch "Finding the number of active database connections" New topic
Author

Finding the number of active database connections

Anil Verghese
Ranch Hand

Joined: Oct 11, 2006
Posts: 155
Hi,

Is it possible to find the number of active connections to a database using java? Am using Mysql.

Regards
Anil
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14480
    
    7

If you're using a database connection pool, you may be able to get stats from it.

At a higher level, you can use OS-level utilities such as netstat to see network connections over the MySQL port.


Customer surveys are for companies who didn't pay proper attention to begin with.
Anil Verghese
Ranch Hand

Joined: Oct 11, 2006
Posts: 155
Hi,


I am using connection pooling, how do i get the stats about the number of connections..

Anil
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
That depends on the pool implementation you are using I'd guess...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3652

You should check on the database side, not the java side. MySQL Administrator comes with a statistics package that will tell you the number of connections.

In general, there should be enough connections for the system to routinely get a database connection without much delay. If you need to configure connection pooling or your DBMS system, generally it should be analyzed and done on a level above the base Java code. For example, its rare to check available connection information in a large J2EE system every time you request a data access object.
[ May 06, 2008: Message edited by: Scott Selikoff ]

My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Finding the number of active database connections
 
Similar Threads
Tomcat hanging
inforamtion regarding database connections in weblogic 9.1
connection pooling
Help with OracleConnectionCacheImpl
Active Connections