• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding the number of active database connections

 
Anil Verghese
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Anil Verghese
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


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

Anil
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends on the pool implementation you are using I'd guess...
 
Scott Selikoff
author
Saloon Keeper
Posts: 4031
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic