I have a connection problem to a MySQL database from a C++ program:
std::string server, user, password;
SetParams(server, user, password);
boost::shared_ptr<sql::Connection> conn;
sql::Driver *driver = get_driver_instance();
if(driver == 0) { /* error; never reached */ }
try {
conn.reset(driver->connect(server, user, password));
assert(conn != 0);
if(!conn->isClosed()) // <-- exception thrown
{
// Connection established
}
else {
// Connection failed
}
}
catch (sql::SQLException &e)
{
cerr << e.what << e.getErrorCode() << e.getSQLState() << endl;
}
The sql::Connection::isClosed() function throws this exception:
SQLException: Connection has been closed
MySQL error code: 0
SQLState: HY000
The values for server, user and password are correct (they work connecting from MySQL-Workbench), the DB is up and running.
I do not know where else to look...
Thank you.
Platform:
Linux - OpenSuse 11.4
MySQL 5.x
MySQL Connector/C++ 1.0.5
*** UPDATE ***
The code as shown here works correctly. The problem must be somewhere else in the program...
std::string server, user, password;
SetParams(server, user, password);
boost::shared_ptr<sql::Connection> conn;
sql::Driver *driver = get_driver_instance();
if(driver == 0) { /* error; never reached */ }
try {
conn.reset(driver->connect(server, user, password));
assert(conn != 0);
if(!conn->isClosed()) // <-- exception thrown
{
// Connection established
}
else {
// Connection failed
}
}
catch (sql::SQLException &e)
{
cerr << e.what << e.getErrorCode() << e.getSQLState() << endl;
}
The sql::Connection::isClosed() function throws this exception:
SQLException: Connection has been closed
MySQL error code: 0
SQLState: HY000
The values for server, user and password are correct (they work connecting from MySQL-Workbench), the DB is up and running.
I do not know where else to look...
Thank you.
Platform:
Linux - OpenSuse 11.4
MySQL 5.x
MySQL Connector/C++ 1.0.5
*** UPDATE ***
The code as shown here works correctly. The problem must be somewhere else in the program...