c# - How to query the current size of the MySQL's .Net connector's connection pool? -
is there programmatic way find current number of open connections database beingness maintained .net connector/mysql.data.dll?
i'm interested in collecting info within same programme library used.
connection pooling performed on client side. access it, you'll need utilize reflection mysqlpoolmanager , mysqlpool classes, both internal mysql.data assembly.
essentially, you'll want utilize reflection 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'll notice have pass in mysqlconnectionstringbuilder
object. creates separate pool each connection string, utilize same connection string utilize in app (it needs identical).
you can access private pool fields , properties (again, using reflection), info need. in particular, "available" field , "numconnections" properties of involvement you. there's "idlepool" (a queue<>
) , "inusepool" (a list<>
) can access well, particularly counts.
c# mysql
No comments:
Post a Comment