【发布时间】:2014-03-27 10:36:45
【问题描述】:
我在 C++、Ubuntu (12.04) 和 MySQL 5.5 x64 上使用 Poco(1.5.2 版)。
我尝试使用以下代码连接到 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;
}
但是有一个 MySQLException:
错误:MySQL
这是什么意思?有没有人可以帮助我?
谢谢!!
编辑:好的,这个错误是一个错误的库链接:p 我使用了一个来自错误 MySQL 版本的库 ^^
【问题讨论】:
-
你应该回答你自己的问题(或删除它)。
标签: c++ mysql poco-libraries