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?
答案 0 :(得分:1)
函数mysql_thread_id()需要一个指向由本机MySQL C API的mysql_connect(...)函数创建的连接对象的指针。 Connector / C ++已将该对象埋藏得非常深(我看)。 MySQL文档here建议的替代方法是执行查询EXEC SQL SELECT (y).p_foo, (y).p_bar into :foo,:bar from (select foobar() y) x;
,返回的结果将是您要查找的ID。