使用Poco与MySQL的连接失败 我在C++上使用PoCO(1.5.2VER),在Ubuntu(12.04)上使用MySQL 5.5 x64 .

使用Poco与MySQL的连接失败 我在C++上使用PoCO(1.5.2VER),在Ubuntu(12.04)上使用MySQL 5.5 x64 .,c++,mysql,poco-libraries,C++,Mysql,Poco Libraries,我尝试使用以下代码连接到MySQL: #include <iostream> #include <Poco/Data/MySQL/MySQLException.h> #include <Poco/Data/MySQL/Connector.h> #include <Poco/Data/SessionFactory.h> using namespace std; int main() { Poco::Data::MySQL::Connec

我尝试使用以下代码连接到MySQL:

#include <iostream>

#include <Poco/Data/MySQL/MySQLException.h>
#include <Poco/Data/MySQL/Connector.h>
#include <Poco/Data/SessionFactory.h>

using namespace std;

int main()
{
    Poco::Data::MySQL::Connector::registerConnector();
    try
    {
        string chaine = "host=localhost;user=root;password=mypassword;";
        Poco::Data::Session test(Poco::Data::SessionFactory::instance().create(Poco::Data::MySQL::Connector::KEY, chaine));
    }
    catch(Poco::Data::MySQL::MySQLException& e)
    {
        cout << "Error: " << e.what() << endl;
    }
    return 0;
}
#包括
#包括
#包括
#包括
使用名称空间std;
int main()
{
Poco::Data::MySQL::Connector::registerConnector();
尝试
{
string chaine=“host=localhost;user=root;password=mypassword;”;
Poco::Data::Session测试(Poco::Data::SessionFactory::instance().create(Poco::Data::MySQL::Connector::KEY,chaine));
}
catch(Poco::Data::MySQL::MySQLException&e)
{

cout正如我在第一条消息中所说,这个bug是一个坏的库链接。我使用了一个来自坏的MySQL版本的库^^

我希望这篇文章能帮助那些遇到同样问题的人。

使用displayText()获取详细的异常消息:

catch(Poco::Data::MySQL::MySQLException& e)
{
    std::cout << "Error: " << e.displayText() << '\n';
}
catch(Poco::Data::MySQL::MySQLException&e) {
你能回答你自己的问题吗(或者删除它)。