#include #include #include int main(int argc, char *argv[]) { MYSQL *mysql; int i, count; const char *host; unsigned int port; const char *user; const char *passwd; if (argc != 6) { printf("Usage: %s count host port user passwd\n", argv[0]); return 1; } count = atoi(argv[1]); host = argv[2]; port = atoi(argv[3]); user = argv[4]; passwd = argv[5]; for (i = 0; i < count; ++i) { if (mysql_library_init(-1, NULL, NULL) != 0) { printf("mysql_library_init failed"); return 1; } mysql = mysql_init(NULL); if (!mysql) { printf("mysql_init failed"); return 1; } if (!mysql_real_connect(mysql, host, user, passwd, NULL, port, NULL, 0)) { printf("mysql_real_connect failed: %s\n", mysql_error(mysql)); return 1; } if (mysql_query(mysql, "SELECT NULL LIMIT 0") != 0) { printf("mysql_query failed: %s\n", mysql_error(mysql)); return 1; } mysql_close(mysql); mysql_library_end(); } return 0; }