I have a program that connects to a MySQL database and will continue to live for a very long time. It can occur that there are more than 8h between queries to the server. As a consequence, I get the following error :
Error in TMySQLServer::Statement: Code: 2006 Msg: MySQL server has gone away
I tried to use PingVerify() on the server object to see what it does. It says :
Error in TMySQLServer::PingVerify: not able to automatically reconnect a second time
Error in TMySQLServer::Ping: Code: 2006 Msg: MySQL server has gone away
Ping verify : 0
My question is simple : how do I specify that I want an automatic reconnection ? I would need to call mysql_options(…, MYSQL_OPT_RECONNECT, …) but I can’t… Or I don’t see how.
Could you provide a wrapper method in TMySQLServer for mysql_options ?
Or at least an extended list of accepted parameters in the TMySQLServer object ?
For the moment the way mysql options delivered via ROOT interface - additional arguments for TSQLServer::Connect operation. They are described in TMySQLServer constructor root.cern.ch/root/html/TMySQLSer … ySQLServer
Unfortunately, there is no way to specify reconnect option MYSQL_OPT_RECONNECT. Actully, it was added only in MySQL version 5 after ROOT MySQL plugin was finished. I can easily add it. Have you other options that you missed?
It is what I noticed, but I think this is a bit static in the sense that you have to modify source code each time there is a request to access a new option. Couldn’t you add a method that would wrap mysql_options ?
you see that mysql_options should be called BEFORE mysql_real_connect is called. Means you should set options before you create MySQLServer instance . Therefore, with current concept of TSQLServer::Connect() it is not easy to provide that you want. I propose to add several options, like reconnect, as I did before. You also can use my.cnf file to set most options there.
Changes are now in svn repository.
You can set reconnect attribute and also few more options.
See TMySQLServer constructor for more details.
I guess, most of other staff you can set via custom my.cnf file.