#include #include #include int main() { MYSQL *mysql = 0; MYSQL_STMT *stmt1, *stmt2; const char *query = "SELECT CURRENT_TIMESTAMP"; mysql = mysql_init(0); if (!mysql_real_connect(mysql, "localhost", "user", "password", "database", 3306, 0, 0)) { fprintf(stderr, "cannot connect: %s\n", mysql_error(mysql)); return 1; } if (mysql_query(mysql, "SET session wait_timeout=3")) { fprintf(stderr, "cannot set the session timeout: %s\n", mysql_error(mysql)); return 1; } stmt1 = mysql_stmt_init(mysql); if (mysql_stmt_prepare(stmt1, query, strlen(query))) { fprintf(stderr, "cannot prepare statement1: %s\n", mysql_stmt_error(stmt1)); return 1; } sleep(5); stmt2 = mysql_stmt_init(mysql); if (mysql_stmt_prepare(stmt2, query, strlen(query))) { fprintf(stderr, "cannot prepare statement2: %s\n", mysql_stmt_error(stmt2)); } mysql_stmt_close(stmt2); mysql_stmt_close(stmt1); return 0; }