wizurd
wizurd

Reputation: 3739

MySQL C++ Connector: How do I get the thread/connection Id?

I'm trying to find out how to obtain the MySQL Connection/thread id using Connector C++.

mysql_thread_id(MYSQL* ) seems to be available for just this, but I'm not sure how to get an instance of MYSQL from the Connector C++.

What I've tried:

  int threadId = mysql_thread_id(NULL);

But this just returns zero.

Any ideas?

Upvotes: 0

Views: 522

Answers (1)

Josh Benson
Josh Benson

Reputation: 236

The function mysql_thread_id() expects a pointer to a connection object created by the native MySQL C API's mysql_connect(...) function. Connector/C++ has buried that object very deep (I looked). The alternative suggested by MySQL's documentation here is to execute query SELECT CONNECTION_ID() and the returned result will be the ID you're looking for.

Upvotes: 1

Related Questions