On 7/20/2010 8:17 AM, Martin Dubuc wrote:
>
> This code used to work on both CentOS 5.4 (mysql-5.0.77-3) and Fedora 13
> when using the 3.0.9 version of mysql++, but since I upgraded to mysql++
> 3.1.0 and CentOS 5.5, the connect call fails with error "Option can only be
> set while the connection is established" on CentOS 5.5, although it works on
> Fedora 13.
From the 3.1.0 section of the MySQL++ ChangeLog:
o ReconnectOption behavior now knows about a fix in MySQL 5.1.6 and
newer that lets you set it either before the connection is up,
or after. If you try to set this option when MySQL++ is built
against earlier versions of the MySQL C API, it will refuse to
set the option because it knows the option will be reset when
the connection comes up.
The truth about your observation that "it used to work" is that it
didn't do what you thought it did.
While you could just move the set_option() call to after the connect()
call, it'd be better to upgrade to the current MySQL 5.1 release and
leave your code the same, as that avoids a race condition.