In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
In the past, mysql used version 3.23, when calling C API, there was basically no reconnection setting, but now using mysql5.1, I found that the connection would be broken every morning, which was very strange. I checked the document carefully and found that there were two parameters: interactive_timeout,wait_timeout (default is 28800 seconds), which means that if there is no action in 28800 seconds, the connection will be broken automatically. But the strange thing is why 3.23 also has this parameter but does not happen. Is that a problem? Later, it is found that after 5.0.3, the default is not to reconnect automatically after the timeout is broken. If you need to set it to automatic reconnection, you need to use mysql_options () to set MYSQL_OPT_RECONNECT to 1 after mysql_init (), so you can reconnect automatically!
Here are the connected functions:
Int xdbmysql_connect (XdbMysqlBackend * self, const char * host, const char * port
Const char * user, const char * pass, const char * db)
{
Int nport
Char value = 1
If (! port | | sscanf (port, "% d", & nport)
< 1) nport = 0; mysql_init(&(self->Mysql))
Mysql_options (& (self- > mysql), MYSQL_OPT_RECONNECT, (char *) & value)
Self- > connection = mysql_real_connect (& (self- > mysql), host, user, pass
Db, nport, NULL, 0)
If (! xdbmysql_is_connected (self))
Return 0
/ / add by zld (b)
Strcpy (st_ui.host,host)
Strcpy (st_ui.port,port)
Strcpy (st_ui.usr,user)
Strcpy (st_ui.pwd,pass)
Strcpy (st_ui.dbn,db)
/ / add by zld (e)
Return 1
}
[@ more@]
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.