The connection pool is client-side. To access it, you need to use reflection to go to the MySqlPoolManager and MySqlPool classes, which are internal to the MySql.Data assembly.
Essentially, you'll want to use reflection to get to the pool. Here's how:
Assembly ms = Assembly.LoadFrom("MySql.Data.dll"); Type type = ms.GetType("MySql.Data.MySqlClient.MySqlPoolManager"); MethodInfo mi = type.GetMethod("GetPool", BindingFlags.Static | BindingFlags.Public); var pool = mi.Invoke(null, new object[] { new MySqlConnectionStringBuilder(connString) });
You will notice that you need to pass the MySqlConnectionStringBuilder object. It creates a separate pool for each connection string, so use the same connection string that you use in your application (it should be completely identical).
Then you can access the fields and properties of the private pool (again, using reflection) to get the necessary information. In particular, the "available" field and the "NumConnections" properties are likely to be of interest to you. There is also "idlePool" (a Queue<> ) and "inUsePool" (a List<> ), which you can also access, especially counters.
source share