5 #include <mysql++/mysql++.h>
7 namespace remote
{ namespace mcs
{
9 //using namespace mysqlpp;
11 /** The mysql++ database connection handler class handles the database connection and
12 * reconnects when needed.
14 class ManagedConnection
20 virtual ~ManagedConnection();
21 /** Connect to the specified database
22 * \param db Database name
23 * \param host Host name
24 * \param user User name
25 * \param password Password
26 * \returns true if connection is successful
28 bool connect (std::string db
, std::string host
, std::string user
, std::string password
);
30 * \param check If true, check if the connection is alive.
31 * \returns A reference to the current connection object
33 mysqlpp::Connection
& getConnection(bool check
=true);
35 /** Check if the database connection is still alive and try to reconnect if not. **/
36 void checkDBConnection();
37 /** The database connection object **/
38 mysqlpp::Connection sqlConn
;
49 extern ManagedConnection dbConn
;