From the documentation , I know how to check MySql connection state in C++
These methods can be used to check the connection state or reconnect:
sql::Connection::isValid() checks whether the connection is alive.
sql::Connection::reconnect() reconnects if the connection has gone down.
Is there a C API to do the same thing?
Yes, the link you shared is to Connector/C++, which is a C++ API. What you're looking for is Connector/C , or just the regular C API .
mysql_stat
is a function which will return status of the server to tell you if the connection is gone.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.