使用Poco连接MySQL失败
Connection failing with MySQL using Poco
我使用Poco (1.5.2 ver)在c++上,在Ubuntu(12.04)上,MySQL 5.5 x64。
我试着用下面的代码连接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错误:
这是什么意思?有人能帮我吗?
谢谢!!
编辑:ok这个bug是一个坏的库链接:p我使用了一个来自一个坏的MySQL版本的库^^
使用displayText()获取详细的异常消息:
catch(Poco::Data::MySQL::MySQLException& e)
{
std::cout << "Error: " << e.displayText() << 'n';
}
正如我在第一条消息中所说的,这个bug是一个错误的库链接。我使用的lib来自一个糟糕的MySQL版本^^
我希望这篇文章能帮助到有同样问题的人。
相关文章:
- 如果没有malloc,链表实现将失败
- 模板参数替换失败,并且未完成隐式转换
- 具有默认模板参数的多态类的模板推导失败
- C++MySQL C api用户输入行
- 视图中的参数推导失败:take_while
- 链接到自行创建的dll失败
- 带有特殊路径部分的"std::filesystem::weakly_canonical"失败
- GetShortPathName在网络驱动器上使用中文文件夹时失败
- gcc和c++17的过载解析失败
- 为什么使用 P/Invoke 调用 dll 时,某些计算机中的 LoadLibrary 失败?
- 在WSL:configure_file上对config_file的每次调用都失败:配置文件时出现问题
- 使用cmake从源代码构建MySQL连接器/C++失败(与以前的声明冲突)
- Mysql++ 简单脚本编译失败
- 编译MySQL连接器/C++的examples/standalone_example.cpp失败
- mysql c++连接器错误:连接器命令失败,退出代码为1
- MySQL++-运行时检查失败#2-变量周围的堆栈已损坏
- MYSQL总是返回失败
- Mysql ++查询失败
- 连接尝试失败 MySQL poco.
- 使用Poco连接MySQL失败