Thread ID for MySqlConnection object

Thread ID for MySqlConnection object

Postby kazachok » Fri 15 Sep 2006 11:39

Hello everyone,
How can I obtain the Thread ID (or Connection ID identified by the server) for a given connection?
I was not able, so far, to retrieve this value from the MySqlConnection object yet, however, you can see it in debugger. Look at the "Session" property that is not accessible as a Public property, but is visible through the debugger. This "Session contains a variable "b" that holds the value of the Thread ID.

How can i get that thread id?

Are you planning to have this propery accessible to us - developers via a Propery or a getter method?
If not could you explain how can I get that value using reflection

Thank you for your time and consideration.

By the way, when is the next release? I need that fix on Begin/End execute reader (Different post)

good day.

Posts: 25
Joined: Fri 21 Oct 2005 12:38

Postby Serious » Mon 18 Sep 2006 07:34

There is no sense to enrich MySQLDirect .NET interface while you can
retrieve connection id using CONNECTION_ID() function in sql query.

Please describe why do you need Connection ID. We can enrich MySqlConnection interface to perform tasks you need using our internal functionality. Manipulating with internal properties (like connection id) is not a good practice, correct way is to use only public interface of data provider.

Postby kazachok » Mon 18 Sep 2006 11:19

Thanks for your responce.
I didn't realize that there is such function.

The reason for having the Conneciton ID as a Property will allow me to identify the connection without running another SQL command. I completely agree that the manipulation to the connection ID is not a good practice, but the Read-Only property will ensure that the connection id is not modified.

I need to identify all the connections for a given user so that I can "Kill" those connections (or queries only) for administrative purpuses. For example, an application that runs a SHOW FULL PROCESS LIST query to find out who is logged in to the system, then if the Admin user desires, he can "log the particular user off". The only way I can do it is to issue a "KILL thread_id" query. And if the given admin user wants to KILL the connections that he used himself but from the other host machine, he will need to KILL only those connections that have CONNECTION IDs that do not equal to the Connection ID that he is currently connected with.

I hope this explains the "would be nice to have" that CONNECTION ID property as a Read-Only Property on the MySQLConnecito object.

Thank you for your time and help.

By the way, when the new build will be available?
I desperately need that fix to the "EndExecuteReader" behavior.

Posts: 25
Joined: Fri 21 Oct 2005 12:38

Postby Serious » Tue 19 Sep 2006 09:08

We advise you to store connection id each time you open MySqlConnection.

We are testing new build at the moment. It will be available in the nearest future.

Return to dotConnect for MySQL