MySQL Connector++ 使用getString获取表字段数据出错
Linux下一个使用MySQL Connector++ 1.1.0 连接MySQL数据库的程序,在连接数据库获取数据时程序崩溃,
确定数据库中存在记录值,查看Core Dump文件,发现崩溃点发生在调用 MySQL 库的 getString 方法时的那一行,
通过google搜索,发现好一些getString出错的问题,但是多数是Windows下VS编译环境不同造成的,终于发现下面一篇中有和我的问题类似
http://stackoverflow.com/questions/4822958/mysql-c-connector-getstring-doesnt-work-correctly-while-getint-works-perfe
I had a similar problem the program would give a memory exception. Here is what I did to fix it: std::string version = result->getString( COLUMN_NAME ).c_str(); This didn't work: sql::SQLString sString = result->getString( COLUMN_NAME ); <<我的不正常代码是
std::string value = result->getString( field);按照上面的方法将代码修改为
std::string value = result->getString( field).c_str();暂时获取同样的数据没有出错,希望后面也不要出错。
MySQL Connector++ 从版本1.1.4开始编译依赖于BOOST库Popularity: 9% [?]
Random Posts
Comments