Home > database >  C mysql connection for a long time and 8 hours of abnormal problem, consult
C mysql connection for a long time and 8 hours of abnormal problem, consult

Time:10-05

Now need to mysql non-stop work, sometimes more than 8 hours of leisure, then work,
Frequently, mysql_real_connect is unusual, but the program can't catch exceptions and exception handling,
Checked the mysql eight hours, but don't know how to solve,
Seek expert help, thank you very much

Everybody is good, the code is
If (mysql_init (& amp; Mysql)==NULL)
{
Trace2Logger (" initialized mysql failed! \r\n");
return 0;
}
Char value=https://bbs.csdn.net/topics/1;
Mysql_options (& amp; Mysql, MYSQL_OPT_RECONNECT, (char *) & amp; Value);

if(! Mysql_real_connect (& amp; Mysql, IP, user, pass, dbname, port, NULL, 0))
{
Trace2Logger (" connection mysql failed: % s \ r \ n ", mysql_error (& amp; Mysql));
return 0;
}
The else
{
//Trace2Logger (" database connection success \ r \ n ");
return 1;
}

CodePudding user response:

Increase the connect_timeout wait_timeout both parameter values