[英]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++. 我试图找出如何使用连接器C ++获取MySQL连接/线程ID。
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++. mysql_thread_id (MYSQL *)似乎可用于此目的,但是我不确定如何从连接器C ++获取MYSQL实例。
What I've tried: 我试过的
int threadId = mysql_thread_id(NULL);
But this just returns zero. 但这只会返回零。
Any ideas? 有任何想法吗?
The function mysql_thread_id() expects a pointer to a connection object created by the native MySQL C API's mysql_connect(...) function. 函数mysql_thread_id()需要一个指向由本地MySQL C API的mysql_connect(...)函数创建的连接对象的指针。 Connector/C++ has buried that object very deep (I looked).
Connector / C ++已将该对象深埋(我看过)。 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. MySQL文档在此处建议的替代方法是执行查询
SELECT CONNECTION_ID()
,返回的结果将是您要查找的ID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.