Reconnecting to the server
Date: November 12, 2008 06:56AM
How can I reconnect to a server using the same connection variable? To illustrate the problem, I have the following code:
......
mysqlpp::Connection mysqlcon(false);
mysqlcon.connect (some db, some server, some user, some pass);
...do some queries...
mysqlcon.disconnect();
.....
Now everything is working fine until I want to reuse mysqlcon to connect as another user like this:
...do some queries...
mysqlcon.disconnect();
...do some other stuff...
mysqlcon.connect(some db, some server, another user, another pass);
And this is the moment that my application crashes. Does anyone have a solution to this problem? In my program, I store mysqlcon as a global variable so I can use it in different functions. But sometimes I need to log out and reconnect as another user (I'm writing an application for a fitness centre customer service and different people log into it at the reception desk).
I figured I could maybe do this using a connection pool, but isn't there a simpler way to reuse mysqlcon to reconnect to the server?
Sorry, you can't reply to this topic. It has been closed.
© 1995-2008 MySQL AB, 2008- Sun Microsystems, Inc.