mysql C++ connector [mysql-connector-c++-8.0.19-linux-glibc2
mysql C++ connector [mysql-connector-c++-8.0.19-linux-glibc2.12-x86-64bit]
我的应用程序崩溃了:
static sql::Driver *driver=get_driver_instance();
shared_ptr<sql::Connection> con(driver->connect("127.0.0.1:3306","asif", "password"));
con->setSchema("asif"); //it crashes here (segv)
代码直接来自 mysql C++连接器相关站点上提供的示例
我有模式,好像
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| CREBACO |
| asif |
| asif1 |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
8 rows in set (0.00 sec)
mysql> use asif;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------+
| Tables_in_asif |
+----------------+
| tab1 |
| tab2 |
+----------------+
2 rows in set (0.00 sec)
调试时:
#0 __memmove_sse2_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:371
#1 0x00007ffff7301c80 in std::string::append(std::string const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x00007ffff7634efe in sql::SQLString::append (str=..., this=0x7fffffffdc10)
at /export/home/pb2/build/sb_0-32258110-1547655664.03/mysql-connector-c++-1.1.12/cppconn/sqlstring.h:155
#3 sql::mysql::MySQL_Connection::setSchema (this=0x55555578bed0, catalog=...)
at /export/home/pb2/build/sb_0-32258110-1547655664.03/mysql-connector-c++-1.1.12/driver/mysql_connection.cpp:1345
#4 0x000055555555585d in main () at ../Crebaco/main.cpp:25
来自GDB的调用堆栈,我在mysql-connector-c ++ -1.1.12中遇到相同的错误
代码非常简单(这不是答案(,你能试试这段代码连接到你的MYSQL实例吗
//export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/asif/Desktop/QT/Crebaco/mysql-connector-c++-8.0.19-linux-glibc2.12-x86-64bit/lib64
#include <iostream>
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
using namespace std;
#define SERVERSTRING "tcp://127.0.0.1:3306"
#define USER "root"
#define PASSWORD "password"
#define DATABASE "test"
int main()
{
cout<<"Content-Type: application/txtrnrn";
try {
static sql::Driver *driver=get_driver_instance();
shared_ptr<sql::Connection> con(driver->connect("127.0.0.1:3306","asif", "password"));
con->setSchema("asif");
shared_ptr<sql::Statement> stmt(con->createStatement());
shared_ptr<sql::ResultSet> res(stmt->executeQuery("select * from tab1"));
while (res->next()) {
cout << res->getString("name") << endl;
}
}catch(sql::SQLException &e)
{
cout << "# ERR: " << e.what()<<endl;
cout << "MySQL error code: " << e.getErrorCode()<<endl;
//cout << ", SQLState: " << e.getSQLState()<<endl;
}
return 0;
}
相关文章:
- 在C++/Linux中设置单调时钟的一些技巧
- Linux的Cpp上的计时器
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 在Linux中哪里可以找到互斥、未来等的源代码
- 如何在linux终端中同时编译和运行c++代码
- 在Linux for Windows上编译C++代码时出错
- 如何找到锁定Linux futex的C++行
- 在linux上调试巨大的C++项目
- 如何处理linux终端中带有负号(-)的C++中的命令行参数
- c++方法参数只能在linux的发布模式下自行更改
- 在Linux和C++中的Windows上,散列字符串值会产生不同的输出
- 这里在 Linux 中具有"CreatePipe"和"CreateProcessW"功能吗?
- 函数在Windows或Linux上运行时表现不同
- 在Linux下捕获SIGKILL的C++程序
- 在为LINUX创建共享库时,如何避免STL的私有/弱副本
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- 如何在CPP中创建应该在Windows和Linux上运行的套接字?
- mysql C++ connector [mysql-connector-c++-8.0.19-linux-glibc2
- Linux Mint 19 上的 CMake 3.11 无法找到静态的 Boost 库
- 在Linux Mint 19下,从哪里提取wxWidgets的源代码(.cpp文件)用于步骤内部调试